Sophie

Sophie

distrib > Mandriva > 2008.1 > x86_64 > media > main-release > by-pkgid > ea24284f03fd4a8a4b64047514d93f64 > files > 339

lib64kdegames1-devel-3.5.9-2mdv2008.1.x86_64.rpm

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en_US" xml:lang="en_US">

<head>
  <title>libkdegames: kplayer.cpp Source File (libkdegames)</title>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

  <meta http-equiv="Content-Style-Type" content="text/css" />

  <meta http-equiv="pics-label" content='(pics-1.1 "http://www.icra.org/ratingsv02.html" comment "ICRAonline DE v2.0" l gen true for "http://www.kde.org"  r (nz 1 vz 1 lz 1 oz 1 cb 1) "http://www.rsac.org/ratingsv01.html" l gen true for "http://www.kde.org"  r (n 0 s 0 v 0 l 0))' />

  <meta name="trademark" content="KDE e.V." />
  <meta name="description" content="K Desktop Environment Homepage, KDE.org" />
  <meta name="MSSmartTagsPreventParsing" content="true" />
  <meta name="robots" content="all" />

  <link rel="shortcut icon" href="../../favicon.ico" />

<link rel="stylesheet" media="screen" type="text/css" title="APIDOX" href="doxygen.css" />



</head>

<body>

<div id="nav_header_top" align="right">
  <a href="#content" class="doNotDisplay" accesskey="2">Skip to main content ::</a>

  <a href="../.."><img id="nav_header_logo" alt="Home" align="left" src="../../kde_gear_64.png" border="0" /></a>
  <span class="doNotDisplay">::</span>

  <div id="nav_header_title" align="left">KDE API Reference</div>


</div>

<div id="nav_header_bottom" align="right">
  <span class="doNotDisplay">:: <a href="#navigation" accesskey="5">Skip to Link Menu</a><br/></span>
  <div id="nav_header_bottom_right" style="text-align: left;">
/ <a href="../..">API Reference</a>
 / <a href=".">libkdegames</a>
  </div>
</div>


<table id="main" border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
      <td valign="top" class="menuheader" height="0"></td>

  <td id="contentcolumn" valign="top" rowspan="2" >
    <div id="content" style="padding-top: 0px;"><div style="width:100%; margin: 0px; padding: 0px;">
    <a name="content"></a>


<!-- Generated by Doxygen 1.5.5 -->
<h1>kplayer.cpp</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment">    This file is part of the KDE games library</span>
<a name="l00003"></a>00003 <span class="comment">    Copyright (C) 2001 Martin Heni (martin@heni-online.de)</span>
<a name="l00004"></a>00004 <span class="comment">    Copyright (C) 2001 Andreas Beckermann (b_mann@gmx.de)</span>
<a name="l00005"></a>00005 <span class="comment"></span>
<a name="l00006"></a>00006 <span class="comment">    This library is free software; you can redistribute it and/or</span>
<a name="l00007"></a>00007 <span class="comment">    modify it under the terms of the GNU Library General Public</span>
<a name="l00008"></a>00008 <span class="comment">    License version 2 as published by the Free Software Foundation.</span>
<a name="l00009"></a>00009 <span class="comment"></span>
<a name="l00010"></a>00010 <span class="comment">    This library is distributed in the hope that it will be useful,</span>
<a name="l00011"></a>00011 <span class="comment">    but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00012"></a>00012 <span class="comment">    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU</span>
<a name="l00013"></a>00013 <span class="comment">    Library General Public License for more details.</span>
<a name="l00014"></a>00014 <span class="comment"></span>
<a name="l00015"></a>00015 <span class="comment">    You should have received a copy of the GNU Library General Public License</span>
<a name="l00016"></a>00016 <span class="comment">    along with this library; see the file COPYING.LIB.  If not, write to</span>
<a name="l00017"></a>00017 <span class="comment">    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,</span>
<a name="l00018"></a>00018 <span class="comment">    Boston, MA 02110-1301, USA.</span>
<a name="l00019"></a>00019 <span class="comment">*/</span>
<a name="l00020"></a>00020 <span class="comment">/*</span>
<a name="l00021"></a>00021 <span class="comment">    $Id: kplayer.cpp 465369 2005-09-29 14:33:08Z mueller $</span>
<a name="l00022"></a>00022 <span class="comment">*/</span>
<a name="l00023"></a>00023 
<a name="l00024"></a>00024 
<a name="l00025"></a>00025 <span class="preprocessor">#include "kgame.h"</span>
<a name="l00026"></a>00026 <span class="preprocessor">#include "kgameio.h"</span>
<a name="l00027"></a>00027 <span class="preprocessor">#include "kplayer.h"</span>
<a name="l00028"></a>00028 <span class="preprocessor">#include "kgamemessage.h"</span>
<a name="l00029"></a>00029 <span class="preprocessor">#include "kgamepropertyhandler.h"</span>
<a name="l00030"></a>00030 
<a name="l00031"></a>00031 <span class="preprocessor">#include &lt;kdebug.h&gt;</span>
<a name="l00032"></a>00032 <span class="preprocessor">#include &lt;klocale.h&gt;</span>
<a name="l00033"></a>00033 
<a name="l00034"></a>00034 <span class="preprocessor">#include &lt;qbuffer.h&gt;</span>
<a name="l00035"></a>00035 
<a name="l00036"></a>00036 <span class="preprocessor">#include &lt;stdio.h&gt;</span>
<a name="l00037"></a>00037 <span class="preprocessor">#include &lt;assert.h&gt;</span>
<a name="l00038"></a>00038 
<a name="l00039"></a>00039 <span class="preprocessor">#define KPLAYER_LOAD_COOKIE 7285</span>
<a name="l00040"></a>00040 <span class="preprocessor"></span>
<a name="l00041"></a>00041 <span class="keyword">class </span>KPlayerPrivate
<a name="l00042"></a>00042 {
<a name="l00043"></a>00043 <span class="keyword">public</span>:
<a name="l00044"></a>00044    KPlayerPrivate()
<a name="l00045"></a>00045    {
<a name="l00046"></a>00046       mNetworkPlayer = 0;
<a name="l00047"></a>00047    }
<a name="l00048"></a>00048 
<a name="l00049"></a>00049    Q_UINT32 mId;
<a name="l00050"></a>00050    <span class="keywordtype">bool</span> mVirtual; <span class="comment">// virtual player</span>
<a name="l00051"></a>00051    <span class="keywordtype">int</span> mPriority; <span class="comment">// tag for replacement</span>
<a name="l00052"></a>00052 
<a name="l00053"></a>00053    <a class="code" href="classKPlayer.html" title="Base class for a game player.">KPlayer</a>* mNetworkPlayer; <span class="comment">// replacement player</span>
<a name="l00054"></a>00054 
<a name="l00055"></a>00055    <a class="code" href="classKGamePropertyHandler.html" title="A collection class for KGameProperty objects.">KGamePropertyHandler</a> mProperties;
<a name="l00056"></a>00056 
<a name="l00057"></a>00057 <span class="comment">// Playerdata</span>
<a name="l00058"></a>00058    <a class="code" href="classKGameProperty.html">KGamePropertyQString</a> mName;
<a name="l00059"></a>00059    <a class="code" href="classKGameProperty.html">KGamePropertyQString</a> mGroup;
<a name="l00060"></a>00060 };
<a name="l00061"></a>00061 
<a name="l00062"></a><a class="code" href="classKPlayer.html#d5772eda397c45465c41432909e894d7">00062</a> <a class="code" href="classKPlayer.html#d5772eda397c45465c41432909e894d7" title="Create a new player object.">KPlayer::KPlayer</a>() : QObject(0,0)
<a name="l00063"></a>00063 {
<a name="l00064"></a>00064  init();
<a name="l00065"></a>00065 }
<a name="l00066"></a>00066 
<a name="l00067"></a><a class="code" href="classKPlayer.html#8e803e8e2c32705ce9336f7895864a50">00067</a> <a class="code" href="classKPlayer.html#d5772eda397c45465c41432909e894d7" title="Create a new player object.">KPlayer::KPlayer</a>(<a class="code" href="classKGame.html" title="The main KDE game object.">KGame</a>* <a class="code" href="classKPlayer.html#377817feb7e53e5fe6deedc23f399b17" title="Query to which game the player belongs to.">game</a>) : QObject(0, 0)
<a name="l00068"></a>00068 {
<a name="l00069"></a>00069  init();
<a name="l00070"></a>00070  game-&gt;<a class="code" href="classKGame.html#4e2c90c3dc1aa46435cbd6ab0fd60a85" title="Note that KPlayer::save must be implemented properly, as well as KPlayer::rtti This...">addPlayer</a>(<span class="keyword">this</span>);
<a name="l00071"></a>00071 }
<a name="l00072"></a>00072 
<a name="l00073"></a>00073 <span class="keywordtype">void</span> KPlayer::init()
<a name="l00074"></a>00074 {
<a name="l00075"></a>00075 <span class="comment">// note that NO KGame object exists here! so we cannot use KGameProperty::send!</span>
<a name="l00076"></a>00076    kdDebug(11001) &lt;&lt; k_funcinfo &lt;&lt; <span class="stringliteral">": this="</span> &lt;&lt; <span class="keyword">this</span> &lt;&lt; <span class="stringliteral">", sizeof(this)="</span>&lt;&lt;<span class="keyword">sizeof</span>(<a class="code" href="classKPlayer.html" title="Base class for a game player.">KPlayer</a>) &lt;&lt; endl;
<a name="l00077"></a>00077    kdDebug(11001) &lt;&lt; <span class="stringliteral">"sizeof(m_Group)="</span>&lt;&lt;<span class="keyword">sizeof</span>(d-&gt;mGroup)&lt;&lt;endl;
<a name="l00078"></a>00078    d = <span class="keyword">new</span> KPlayerPrivate;
<a name="l00079"></a>00079 
<a name="l00080"></a>00080    d-&gt;mProperties.registerHandler(KGameMessage::IdPlayerProperty,
<a name="l00081"></a>00081                                   <span class="keyword">this</span>,SLOT(<a class="code" href="classKPlayer.html#106419f5d156a580895eb04b7bd4288f" title="Called by KGameProperty only! Internal function!">sendProperty</a>(<span class="keywordtype">int</span>, QDataStream&amp;, <span class="keywordtype">bool</span>*)),
<a name="l00082"></a>00082                                        SLOT(<a class="code" href="classKPlayer.html#717226c69acbd6df2747d683565f9fda" title="Called by KGameProperty only! Internal function!">emitSignal</a>(<a class="code" href="classKGamePropertyBase.html" title="Base class of KGameProperty.">KGamePropertyBase</a> *)));
<a name="l00083"></a>00083    d-&gt;mVirtual=<span class="keyword">false</span>;
<a name="l00084"></a>00084    mActive=<span class="keyword">true</span>;
<a name="l00085"></a>00085    mGame=0;
<a name="l00086"></a>00086    d-&gt;mId=0; <span class="comment">// "0" is always an invalid ID!</span>
<a name="l00087"></a>00087    d-&gt;mPriority=0;
<a name="l00088"></a>00088    <span class="comment">// I guess we cannot translate the group otherwise no</span>
<a name="l00089"></a>00089    <span class="comment">// international conenctions are possible</span>
<a name="l00090"></a>00090 
<a name="l00091"></a>00091    mUserId.<a class="code" href="classKGamePropertyBase.html#185d99416b87cc55d14a80a67ef9d9aa" title="You have to register a KGamePropertyBase before you can use it.">registerData</a>(KGamePropertyBase::IdUserId, <span class="keyword">this</span>, i18n(<span class="stringliteral">"UserId"</span>));
<a name="l00092"></a>00092    mUserId.<a class="code" href="classKGameProperty.html#fd47964f181f5980af9b1adec5d24fb1" title="This function sets the value of the property directly, i.e.">setLocal</a>(0);
<a name="l00093"></a>00093    d-&gt;mGroup.registerData(KGamePropertyBase::IdGroup, <span class="keyword">this</span>, i18n(<span class="stringliteral">"Group"</span>));
<a name="l00094"></a>00094    d-&gt;mGroup.setLocal(i18n(<span class="stringliteral">"default"</span>));
<a name="l00095"></a>00095    d-&gt;mName.registerData(KGamePropertyBase::IdName, <span class="keyword">this</span>, i18n(<span class="stringliteral">"Name"</span>));
<a name="l00096"></a>00096    d-&gt;mName.setLocal(i18n(<span class="stringliteral">"default"</span>));
<a name="l00097"></a>00097 
<a name="l00098"></a>00098    mAsyncInput.<a class="code" href="classKGamePropertyBase.html#185d99416b87cc55d14a80a67ef9d9aa" title="You have to register a KGamePropertyBase before you can use it.">registerData</a>(KGamePropertyBase::IdAsyncInput, <span class="keyword">this</span>, i18n(<span class="stringliteral">"AsyncInput"</span>));
<a name="l00099"></a>00099    mAsyncInput.<a class="code" href="classKGameProperty.html#fd47964f181f5980af9b1adec5d24fb1" title="This function sets the value of the property directly, i.e.">setLocal</a>(<span class="keyword">false</span>);
<a name="l00100"></a>00100    mMyTurn.<a class="code" href="classKGamePropertyBase.html#185d99416b87cc55d14a80a67ef9d9aa" title="You have to register a KGamePropertyBase before you can use it.">registerData</a>(KGamePropertyBase::IdTurn, <span class="keyword">this</span>, i18n(<span class="stringliteral">"myTurn"</span>));
<a name="l00101"></a>00101    mMyTurn.<a class="code" href="classKGameProperty.html#fd47964f181f5980af9b1adec5d24fb1" title="This function sets the value of the property directly, i.e.">setLocal</a>(<span class="keyword">false</span>);
<a name="l00102"></a>00102    mMyTurn.<a class="code" href="classKGamePropertyBase.html#47512e7fc6657f60e3b4112ae7d5b091" title="Sets this property to emit a signal on value changed.">setEmittingSignal</a>(<span class="keyword">true</span>);
<a name="l00103"></a>00103    mMyTurn.<a class="code" href="classKGamePropertyBase.html#3db9f94619d7306cf5c3e63179822db6" title="Sets this property to try to optimize signal and network handling by not sending...">setOptimized</a>(<span class="keyword">false</span>);
<a name="l00104"></a>00104 }
<a name="l00105"></a>00105 
<a name="l00106"></a>00106 KPlayer::~KPlayer()
<a name="l00107"></a>00107 {
<a name="l00108"></a>00108   kdDebug(11001) &lt;&lt; k_funcinfo &lt;&lt; <span class="stringliteral">": this="</span> &lt;&lt; <span class="keyword">this</span> &lt;&lt;<span class="stringliteral">", id="</span> &lt;&lt; this-&gt;<a class="code" href="classKPlayer.html#a1151863225396c0f96678bf3ca938ae" title="Returns the id of the player.">id</a>() &lt;&lt; endl;
<a name="l00109"></a>00109 
<a name="l00110"></a>00110   <span class="comment">// Delete IODevices</span>
<a name="l00111"></a>00111   <a class="code" href="classKGameIO.html" title="Base class for IO devices for games.">KGameIO</a> *input;
<a name="l00112"></a>00112   <span class="keywordflow">while</span>((input=mInputList.first()))
<a name="l00113"></a>00113   {
<a name="l00114"></a>00114     <span class="keyword">delete</span> input;
<a name="l00115"></a>00115   }
<a name="l00116"></a>00116   <span class="keywordflow">if</span> (<a class="code" href="classKPlayer.html#377817feb7e53e5fe6deedc23f399b17" title="Query to which game the player belongs to.">game</a>())
<a name="l00117"></a>00117   {
<a name="l00118"></a>00118     <a class="code" href="classKPlayer.html#377817feb7e53e5fe6deedc23f399b17" title="Query to which game the player belongs to.">game</a>()-&gt;<a class="code" href="classKGame.html#b49c38e1cd04316ef7ecae3033057d89" title="Called by the destructor of KPlayer to remove itself from the game.">playerDeleted</a>(<span class="keyword">this</span>);
<a name="l00119"></a>00119   }
<a name="l00120"></a>00120 
<a name="l00121"></a>00121 <span class="comment">// note: mProperties does not use autoDelete or so - user must delete objects</span>
<a name="l00122"></a>00122 <span class="comment">// himself</span>
<a name="l00123"></a>00123   d-&gt;mProperties.clear();
<a name="l00124"></a>00124   <span class="keyword">delete</span> d;
<a name="l00125"></a>00125 <span class="comment">//  kdDebug(11001) &lt;&lt; k_funcinfo &lt;&lt; " done" &lt;&lt; endl;</span>
<a name="l00126"></a>00126 }
<a name="l00127"></a>00127 
<a name="l00128"></a><a class="code" href="classKPlayer.html#c1c3f9a4267e6c9c9b15c3cf73a154dc">00128</a> <span class="keywordtype">bool</span> <a class="code" href="classKPlayer.html#c1c3f9a4267e6c9c9b15c3cf73a154dc" title="Forwards Message to the game object.">KPlayer::forwardMessage</a>(QDataStream &amp;msg,<span class="keywordtype">int</span> msgid,Q_UINT32 receiver,Q_UINT32 sender)
<a name="l00129"></a>00129 {
<a name="l00130"></a>00130   <span class="keywordflow">if</span> (!<a class="code" href="classKPlayer.html#06b52c8144adfddd8c27aef72829f74c" title="Is this player an active player.">isActive</a>())
<a name="l00131"></a>00131   {
<a name="l00132"></a>00132     <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00133"></a>00133   }
<a name="l00134"></a>00134   <span class="keywordflow">if</span> (!<a class="code" href="classKPlayer.html#377817feb7e53e5fe6deedc23f399b17" title="Query to which game the player belongs to.">game</a>())
<a name="l00135"></a>00135   {
<a name="l00136"></a>00136     <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00137"></a>00137   }
<a name="l00138"></a>00138   kdDebug(11001) &lt;&lt; k_funcinfo &lt;&lt; <span class="stringliteral">": to game sender="</span>&lt;&lt;sender&lt;&lt;<span class="stringliteral">""</span> &lt;&lt; <span class="stringliteral">"recv="</span>&lt;&lt;receiver &lt;&lt;<span class="stringliteral">"msgid="</span>&lt;&lt;msgid &lt;&lt; endl;
<a name="l00139"></a>00139   <span class="keywordflow">return</span> <a class="code" href="classKPlayer.html#377817feb7e53e5fe6deedc23f399b17" title="Query to which game the player belongs to.">game</a>()-&gt;<a class="code" href="classKGameNetwork.html#47378d52be82b84762a27dff42f54295" title="Sends a network message msg with a given msg id msgid to all clients.">sendSystemMessage</a>(msg,msgid,receiver,sender);
<a name="l00140"></a>00140 }
<a name="l00141"></a>00141 
<a name="l00142"></a><a class="code" href="classKPlayer.html#41572b54137d6c26cd426a2d450c7afc">00142</a> <span class="keywordtype">bool</span> <a class="code" href="classKPlayer.html#41572b54137d6c26cd426a2d450c7afc" title="Forwards input to the game object.">KPlayer::forwardInput</a>(QDataStream &amp;msg,<span class="keywordtype">bool</span> transmit,Q_UINT32 sender)
<a name="l00143"></a>00143 {
<a name="l00144"></a>00144   <span class="keywordflow">if</span> (!<a class="code" href="classKPlayer.html#06b52c8144adfddd8c27aef72829f74c" title="Is this player an active player.">isActive</a>())
<a name="l00145"></a>00145   {
<a name="l00146"></a>00146     <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00147"></a>00147   }
<a name="l00148"></a>00148   <span class="keywordflow">if</span> (!<a class="code" href="classKPlayer.html#377817feb7e53e5fe6deedc23f399b17" title="Query to which game the player belongs to.">game</a>())
<a name="l00149"></a>00149   {
<a name="l00150"></a>00150     <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00151"></a>00151   }
<a name="l00152"></a>00152 
<a name="l00153"></a>00153   kdDebug(11001) &lt;&lt; k_funcinfo &lt;&lt; <span class="stringliteral">": to game playerInput(sender="</span>&lt;&lt;sender&lt;&lt;<span class="stringliteral">")"</span> &lt;&lt; endl;
<a name="l00154"></a>00154   <span class="keywordflow">if</span> (!<a class="code" href="classKPlayer.html#ff79f9d54b46b8cb166735cebf93d13a" title="Query whether this player does asynchronous input.">asyncInput</a>() &amp;&amp; !<a class="code" href="classKPlayer.html#20dcc5d9f7f2ada1a5dbcafa44ade404" title="is it my turn to go">myTurn</a>())
<a name="l00155"></a>00155   {
<a name="l00156"></a>00156     kdDebug(11001) &lt;&lt; k_funcinfo &lt;&lt; <span class="stringliteral">": rejected cause it is not our turn"</span> &lt;&lt; endl;
<a name="l00157"></a>00157     <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00158"></a>00158   }
<a name="l00159"></a>00159 
<a name="l00160"></a>00160   <span class="comment">// AB: I hope I remember the usage correctly:</span>
<a name="l00161"></a>00161   <span class="comment">// this function is called twice (on sender side) - once with transmit = true</span>
<a name="l00162"></a>00162   <span class="comment">// where it sends the input to the comserver and once with transmit = false</span>
<a name="l00163"></a>00163   <span class="comment">// where it really looks at the input</span>
<a name="l00164"></a>00164   <span class="keywordflow">if</span> (transmit)
<a name="l00165"></a>00165   {
<a name="l00166"></a>00166     kdDebug(11001) &lt;&lt; <span class="stringliteral">"indirect playerInput"</span> &lt;&lt; endl;
<a name="l00167"></a>00167     <span class="keywordflow">return</span> <a class="code" href="classKPlayer.html#377817feb7e53e5fe6deedc23f399b17" title="Query to which game the player belongs to.">game</a>()-&gt;<a class="code" href="classKGame.html#4a7ca7a79b0167817b2ec9ff7d5ead1b" title="Called by KPlayer to send a player input to the KMessageServer.">sendPlayerInput</a>(msg,<span class="keyword">this</span>,sender);
<a name="l00168"></a>00168   }
<a name="l00169"></a>00169   <span class="keywordflow">else</span>
<a name="l00170"></a>00170   {
<a name="l00171"></a>00171     kdDebug(11001) &lt;&lt; <span class="stringliteral">"direct playerInput"</span> &lt;&lt; endl;
<a name="l00172"></a>00172     <span class="keywordflow">return</span> <a class="code" href="classKPlayer.html#377817feb7e53e5fe6deedc23f399b17" title="Query to which game the player belongs to.">game</a>()-&gt;<a class="code" href="classKGame.html#704e7453a4876d7f5d764cf7a037ee96" title="Called when a player input arrives from KMessageServer.">systemPlayerInput</a>(msg,<span class="keyword">this</span>,sender);
<a name="l00173"></a>00173   }
<a name="l00174"></a>00174 }
<a name="l00175"></a>00175 
<a name="l00176"></a>00176 <span class="keywordtype">void</span> KPlayer::setId(Q_UINT32 newid)
<a name="l00177"></a>00177 {
<a name="l00178"></a>00178   <span class="comment">// Needs to be after the sendProcess</span>
<a name="l00179"></a>00179   d-&gt;mId=newid;
<a name="l00180"></a>00180 }
<a name="l00181"></a>00181 
<a name="l00182"></a>00182 
<a name="l00183"></a><a class="code" href="classKPlayer.html#a324632f58cc1f732450cca31a6a106e">00183</a> <span class="keywordtype">void</span> <a class="code" href="classKPlayer.html#a324632f58cc1f732450cca31a6a106e" title="A group the player belongs to.">KPlayer::setGroup</a>(<span class="keyword">const</span> QString&amp; <a class="code" href="classKPlayer.html#300571584f3fb5da37bf56b377131b03" title="Query the group the player belongs to.">group</a>)
<a name="l00184"></a>00184 { d-&gt;mGroup = group; }
<a name="l00185"></a>00185 
<a name="l00186"></a><a class="code" href="classKPlayer.html#300571584f3fb5da37bf56b377131b03">00186</a> <span class="keyword">const</span> QString&amp; <a class="code" href="classKPlayer.html#300571584f3fb5da37bf56b377131b03" title="Query the group the player belongs to.">KPlayer::group</a>()<span class="keyword"> const</span>
<a name="l00187"></a>00187 <span class="keyword"></span>{ <span class="keywordflow">return</span> d-&gt;mGroup.value(); }
<a name="l00188"></a>00188 
<a name="l00189"></a><a class="code" href="classKPlayer.html#9fd83c077a4ef25f48061095e2e40e36">00189</a> <span class="keywordtype">void</span> <a class="code" href="classKPlayer.html#9fd83c077a4ef25f48061095e2e40e36" title="Sets the name of the player.">KPlayer::setName</a>(<span class="keyword">const</span> QString&amp; <a class="code" href="classKPlayer.html#ec005101037bbdf9d445f69a5d6682c9">name</a>)
<a name="l00190"></a>00190 { d-&gt;mName = name; }
<a name="l00191"></a>00191 
<a name="l00192"></a><a class="code" href="classKPlayer.html#ec005101037bbdf9d445f69a5d6682c9">00192</a> <span class="keyword">const</span> QString&amp; <a class="code" href="classKPlayer.html#ec005101037bbdf9d445f69a5d6682c9">KPlayer::name</a>()<span class="keyword"> const</span>
<a name="l00193"></a>00193 <span class="keyword"></span>{ <span class="keywordflow">return</span> d-&gt;mName.value(); }
<a name="l00194"></a>00194 
<a name="l00195"></a><a class="code" href="classKPlayer.html#a1151863225396c0f96678bf3ca938ae">00195</a> Q_UINT32 <a class="code" href="classKPlayer.html#a1151863225396c0f96678bf3ca938ae" title="Returns the id of the player.">KPlayer::id</a>()<span class="keyword"> const</span>
<a name="l00196"></a>00196 <span class="keyword"></span>{ <span class="keywordflow">return</span> d-&gt;mId; }
<a name="l00197"></a>00197 
<a name="l00198"></a><a class="code" href="classKPlayer.html#ed04a331c2abc244028d0b864bb4e443">00198</a> <a class="code" href="classKGamePropertyHandler.html" title="A collection class for KGameProperty objects.">KGamePropertyHandler</a> * <a class="code" href="classKPlayer.html#ed04a331c2abc244028d0b864bb4e443">KPlayer::dataHandler</a>()
<a name="l00199"></a>00199 { <span class="keywordflow">return</span> &amp;d-&gt;mProperties; }
<a name="l00200"></a>00200 
<a name="l00201"></a>00201 <span class="keywordtype">void</span> KPlayer::setVirtual(<span class="keywordtype">bool</span> v)
<a name="l00202"></a>00202 { d-&gt;mVirtual = v; }
<a name="l00203"></a>00203 
<a name="l00204"></a><a class="code" href="classKPlayer.html#dba8765b66df59bf09bb3db3d48e7423">00204</a> <span class="keywordtype">bool</span> <a class="code" href="classKPlayer.html#dba8765b66df59bf09bb3db3d48e7423" title="Is this player a virtual player, ie is it created by mirroring a real player from...">KPlayer::isVirtual</a>()<span class="keyword"> const</span>
<a name="l00205"></a>00205 <span class="keyword"></span>{ <span class="keywordflow">return</span> d-&gt;mVirtual;}
<a name="l00206"></a>00206 
<a name="l00207"></a><a class="code" href="classKPlayer.html#d888d408b5d827f77f0accfd17fb06b7">00207</a> <span class="keywordtype">void</span> <a class="code" href="classKPlayer.html#d888d408b5d827f77f0accfd17fb06b7" title="Sets this network player replacement.">KPlayer::setNetworkPlayer</a>(<a class="code" href="classKPlayer.html" title="Base class for a game player.">KPlayer</a>* p)
<a name="l00208"></a>00208 { d-&gt;mNetworkPlayer = p; }
<a name="l00209"></a>00209 
<a name="l00210"></a><a class="code" href="classKPlayer.html#2c3289b8051dd83816dfd27cac8a4dd0">00210</a> <a class="code" href="classKPlayer.html" title="Base class for a game player.">KPlayer</a>* <a class="code" href="classKPlayer.html#2c3289b8051dd83816dfd27cac8a4dd0" title="Returns the player which got inactivated to allow this player to be set up via network...">KPlayer::networkPlayer</a>()<span class="keyword"> const</span>
<a name="l00211"></a>00211 <span class="keyword"></span>{ <span class="keywordflow">return</span> d-&gt;mNetworkPlayer; }
<a name="l00212"></a>00212 
<a name="l00213"></a><a class="code" href="classKPlayer.html#ce1da9fc9f515e7ccaa28e3a2cad33a5">00213</a> <span class="keywordtype">int</span> <a class="code" href="classKPlayer.html#ce1da9fc9f515e7ccaa28e3a2cad33a5" title="Returns whether this player can be replaced by a network connection player.">KPlayer::networkPriority</a>()<span class="keyword"> const</span>
<a name="l00214"></a>00214 <span class="keyword"></span>{ <span class="keywordflow">return</span> d-&gt;mPriority; }
<a name="l00215"></a>00215 
<a name="l00216"></a><a class="code" href="classKPlayer.html#b7f25abf7957e78143e04963f0bc5d37">00216</a> <span class="keywordtype">void</span> <a class="code" href="classKPlayer.html#b7f25abf7957e78143e04963f0bc5d37" title="Set whether this player can be replaced by a network player.">KPlayer::setNetworkPriority</a>(<span class="keywordtype">int</span> p)
<a name="l00217"></a>00217 { d-&gt;mPriority = p; }
<a name="l00218"></a>00218 
<a name="l00219"></a><a class="code" href="classKPlayer.html#7cf34f66a583cd003b71e9e5648269f3">00219</a> <span class="keywordtype">bool</span> <a class="code" href="classKPlayer.html#7cf34f66a583cd003b71e9e5648269f3" title="Adds an IO device for the player.">KPlayer::addGameIO</a>(<a class="code" href="classKGameIO.html" title="Base class for IO devices for games.">KGameIO</a> *input)
<a name="l00220"></a>00220 {
<a name="l00221"></a>00221   <span class="keywordflow">if</span> (!input)
<a name="l00222"></a>00222   {
<a name="l00223"></a>00223     <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00224"></a>00224   }
<a name="l00225"></a>00225   mInputList.append(input); 
<a name="l00226"></a>00226   input-&gt;<a class="code" href="classKGameIO.html#b34ff5dafad0412c1ee871ed1dd8dba8" title="Init this device by setting the player and e.g.">initIO</a>(<span class="keyword">this</span>); <span class="comment">// set player and init device</span>
<a name="l00227"></a>00227   <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00228"></a>00228 }
<a name="l00229"></a>00229 
<a name="l00230"></a>00230 <span class="comment">// input=0, remove all</span>
<a name="l00231"></a><a class="code" href="classKPlayer.html#86618e1eaaac3788c331107c191cc283">00231</a> <span class="keywordtype">bool</span> <a class="code" href="classKPlayer.html#86618e1eaaac3788c331107c191cc283" title="remove (and delete) a game IO device">KPlayer::removeGameIO</a>(<a class="code" href="classKGameIO.html" title="Base class for IO devices for games.">KGameIO</a> *targetinput,<span class="keywordtype">bool</span> deleteit)
<a name="l00232"></a>00232 {
<a name="l00233"></a>00233   kdDebug(11001) &lt;&lt; k_funcinfo &lt;&lt; <span class="stringliteral">": "</span> &lt;&lt; targetinput &lt;&lt; <span class="stringliteral">" delete="</span> &lt;&lt; deleteit&lt;&lt; endl;
<a name="l00234"></a>00234   <span class="keywordtype">bool</span> result=<span class="keyword">true</span>;
<a name="l00235"></a>00235   <span class="keywordflow">if</span> (!targetinput) <span class="comment">// delete all</span>
<a name="l00236"></a>00236   {
<a name="l00237"></a>00237     <a class="code" href="classKGameIO.html" title="Base class for IO devices for games.">KGameIO</a> *input;
<a name="l00238"></a>00238     <span class="keywordflow">while</span>((input=mInputList.first()))
<a name="l00239"></a>00239     {
<a name="l00240"></a>00240       <span class="keywordflow">if</span> (input) <a class="code" href="classKPlayer.html#86618e1eaaac3788c331107c191cc283" title="remove (and delete) a game IO device">removeGameIO</a>(input,deleteit);
<a name="l00241"></a>00241     }
<a name="l00242"></a>00242   }
<a name="l00243"></a>00243   <span class="keywordflow">else</span>
<a name="l00244"></a>00244   {
<a name="l00245"></a>00245 <span class="comment">//    kdDebug(11001) &lt;&lt; "remove IO " &lt;&lt; targetinput &lt;&lt; endl;</span>
<a name="l00246"></a>00246     <span class="keywordflow">if</span> (deleteit)
<a name="l00247"></a>00247     {
<a name="l00248"></a>00248       <span class="keyword">delete</span> targetinput;
<a name="l00249"></a>00249     }
<a name="l00250"></a>00250     <span class="keywordflow">else</span>
<a name="l00251"></a>00251     {
<a name="l00252"></a>00252       targetinput-&gt;<a class="code" href="classKGameIO.html#78a50548e29d842e03e7b69af1754fbf" title="Sets the player to which this IO belongs to.">setPlayer</a>(0);
<a name="l00253"></a>00253       result=mInputList.remove(targetinput);
<a name="l00254"></a>00254     }
<a name="l00255"></a>00255   }
<a name="l00256"></a>00256   <span class="keywordflow">return</span> result;
<a name="l00257"></a>00257 }
<a name="l00258"></a>00258 
<a name="l00259"></a><a class="code" href="classKPlayer.html#e37c13bf263c15930b1ef0c6848fcd98">00259</a> <a class="code" href="classKGameIO.html" title="Base class for IO devices for games.">KGameIO</a> * <a class="code" href="classKPlayer.html#e37c13bf263c15930b1ef0c6848fcd98" title="Finds the KGameIO devies with the given rtti code.">KPlayer::findRttiIO</a>(<span class="keywordtype">int</span> <a class="code" href="classKPlayer.html#b1127bc679ceac89a3150132a69ff701" title="The idendification of the player.">rtti</a>)<span class="keyword"> const</span>
<a name="l00260"></a>00260 <span class="keyword"></span>{
<a name="l00261"></a>00261   QPtrListIterator&lt;KGameIO&gt; it(mInputList);
<a name="l00262"></a>00262   <span class="keywordflow">while</span> (it.current())
<a name="l00263"></a>00263   {
<a name="l00264"></a>00264     <span class="keywordflow">if</span> (it.current()-&gt;rtti() == rtti)
<a name="l00265"></a>00265     {
<a name="l00266"></a>00266       <span class="keywordflow">return</span> it.current();
<a name="l00267"></a>00267     }
<a name="l00268"></a>00268     ++it;
<a name="l00269"></a>00269   }
<a name="l00270"></a>00270   <span class="keywordflow">return</span> 0;
<a name="l00271"></a>00271 }
<a name="l00272"></a>00272 
<a name="l00273"></a><a class="code" href="classKPlayer.html#112d0803614acfb8664d22dffa34d093">00273</a> <span class="keywordtype">int</span> <a class="code" href="classKPlayer.html#112d0803614acfb8664d22dffa34d093" title="Calculates a checksum over the IO devices.">KPlayer::calcIOValue</a>()
<a name="l00274"></a>00274 {
<a name="l00275"></a>00275   <span class="keywordtype">int</span> value=0;
<a name="l00276"></a>00276   QPtrListIterator&lt;KGameIO&gt; it(mInputList);
<a name="l00277"></a>00277   <span class="keywordflow">while</span> (it.current())
<a name="l00278"></a>00278   {
<a name="l00279"></a>00279     value|=it.current()-&gt;rtti();
<a name="l00280"></a>00280     ++it;
<a name="l00281"></a>00281   }
<a name="l00282"></a>00282   <span class="keywordflow">return</span> value;
<a name="l00283"></a>00283 }
<a name="l00284"></a>00284 
<a name="l00285"></a><a class="code" href="classKPlayer.html#9b1e33982ee4eff13168a747f9f22128">00285</a> <span class="keywordtype">bool</span> <a class="code" href="classKPlayer.html#9b1e33982ee4eff13168a747f9f22128" title="Sets whether this player is the next to turn.">KPlayer::setTurn</a>(<span class="keywordtype">bool</span> b, <span class="keywordtype">bool</span> exclusive)
<a name="l00286"></a>00286 {
<a name="l00287"></a>00287   kdDebug(11001) &lt;&lt; k_funcinfo &lt;&lt; <span class="stringliteral">": "</span> &lt;&lt; <a class="code" href="classKPlayer.html#a1151863225396c0f96678bf3ca938ae" title="Returns the id of the player.">id</a>() &lt;&lt; <span class="stringliteral">" ("</span> &lt;&lt; <span class="keyword">this</span> &lt;&lt; <span class="stringliteral">") to "</span> &lt;&lt; b &lt;&lt; endl;
<a name="l00288"></a>00288   <span class="keywordflow">if</span> (!<a class="code" href="classKPlayer.html#06b52c8144adfddd8c27aef72829f74c" title="Is this player an active player.">isActive</a>())
<a name="l00289"></a>00289   {
<a name="l00290"></a>00290     <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00291"></a>00291   }
<a name="l00292"></a>00292 
<a name="l00293"></a>00293   <span class="comment">// if we get to do an exclusive turn all other players are disallowed</span>
<a name="l00294"></a>00294   <span class="keywordflow">if</span> (exclusive &amp;&amp; b &amp;&amp; <a class="code" href="classKPlayer.html#377817feb7e53e5fe6deedc23f399b17" title="Query to which game the player belongs to.">game</a>())
<a name="l00295"></a>00295   {
<a name="l00296"></a>00296      <a class="code" href="classKPlayer.html" title="Base class for a game player.">KPlayer</a> *player;
<a name="l00297"></a>00297      KGame::KGamePlayerList *list=<a class="code" href="classKPlayer.html#377817feb7e53e5fe6deedc23f399b17" title="Query to which game the player belongs to.">game</a>()-&gt;<a class="code" href="classKGame.html#8474f0391a5391f324a4beadbdf1f7cc" title="Returns a list of all active players.">playerList</a>();
<a name="l00298"></a>00298      <span class="keywordflow">for</span> ( player=list-&gt;first(); player != 0; player=list-&gt;next() )
<a name="l00299"></a>00299      {
<a name="l00300"></a>00300        <span class="keywordflow">if</span> (player==<span class="keyword">this</span>)
<a name="l00301"></a>00301        {
<a name="l00302"></a>00302          <span class="keywordflow">continue</span>;
<a name="l00303"></a>00303        }
<a name="l00304"></a>00304        player-&gt;<a class="code" href="classKPlayer.html#9b1e33982ee4eff13168a747f9f22128" title="Sets whether this player is the next to turn.">setTurn</a>(<span class="keyword">false</span>,<span class="keyword">false</span>);
<a name="l00305"></a>00305      }
<a name="l00306"></a>00306   }
<a name="l00307"></a>00307 
<a name="l00308"></a>00308   <span class="comment">// Return if nothing changed</span>
<a name="l00309"></a>00309   mMyTurn = b;
<a name="l00310"></a>00310 
<a name="l00311"></a>00311   <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00312"></a>00312 }
<a name="l00313"></a>00313 
<a name="l00314"></a><a class="code" href="classKPlayer.html#aba1b54e1c6d770312068c4ef85e9791">00314</a> <span class="keywordtype">bool</span> <a class="code" href="classKPlayer.html#aba1b54e1c6d770312068c4ef85e9791" title="Load a saved player, from file OR network.">KPlayer::load</a>(QDataStream &amp;stream)
<a name="l00315"></a>00315 {
<a name="l00316"></a>00316   Q_INT32 <a class="code" href="classKPlayer.html#a1151863225396c0f96678bf3ca938ae" title="Returns the id of the player.">id</a>,priority;
<a name="l00317"></a>00317   stream &gt;&gt; <span class="keywordtype">id</span> &gt;&gt; priority;
<a name="l00318"></a>00318   setId(<span class="keywordtype">id</span>);
<a name="l00319"></a>00319   <a class="code" href="classKPlayer.html#b7f25abf7957e78143e04963f0bc5d37" title="Set whether this player can be replaced by a network player.">setNetworkPriority</a>(priority);
<a name="l00320"></a>00320 
<a name="l00321"></a>00321   <span class="comment">// Load Player Data</span>
<a name="l00322"></a>00322   <span class="comment">//FIXME: maybe set all properties setEmitSignal(false) before?</span>
<a name="l00323"></a>00323   d-&gt;mProperties.load(stream);
<a name="l00324"></a>00324 
<a name="l00325"></a>00325   Q_INT16 cookie;
<a name="l00326"></a>00326   stream &gt;&gt; cookie;
<a name="l00327"></a>00327   <span class="keywordflow">if</span> (cookie==KPLAYER_LOAD_COOKIE)
<a name="l00328"></a>00328   {
<a name="l00329"></a>00329       kdDebug(11001) &lt;&lt; <span class="stringliteral">"   Player loaded propertly"</span>&lt;&lt;endl;
<a name="l00330"></a>00330   }
<a name="l00331"></a>00331   <span class="keywordflow">else</span>
<a name="l00332"></a>00332   {
<a name="l00333"></a>00333       kdError(11001) &lt;&lt; <span class="stringliteral">"   Player loading error. probably format error"</span>&lt;&lt;endl;
<a name="l00334"></a>00334   }
<a name="l00335"></a>00335 
<a name="l00336"></a>00336   <span class="comment">// emit signalLoad(stream);</span>
<a name="l00337"></a>00337   <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00338"></a>00338 }
<a name="l00339"></a>00339 
<a name="l00340"></a><a class="code" href="classKPlayer.html#5f907a17d2bafb64f027621005691b22">00340</a> <span class="keywordtype">bool</span> <a class="code" href="classKPlayer.html#5f907a17d2bafb64f027621005691b22" title="Save a player to a file OR to network.">KPlayer::save</a>(QDataStream &amp;stream)
<a name="l00341"></a>00341 {
<a name="l00342"></a>00342   stream &lt;&lt; (Q_INT32)<span class="keywordtype">id</span>() &lt;&lt; (Q_INT32)<a class="code" href="classKPlayer.html#ce1da9fc9f515e7ccaa28e3a2cad33a5" title="Returns whether this player can be replaced by a network connection player.">networkPriority</a>();
<a name="l00343"></a>00343 
<a name="l00344"></a>00344   d-&gt;mProperties.save(stream);
<a name="l00345"></a>00345 
<a name="l00346"></a>00346   stream &lt;&lt; (Q_INT16)KPLAYER_LOAD_COOKIE;
<a name="l00347"></a>00347 
<a name="l00348"></a>00348   <span class="comment">//emit signalSave(stream);</span>
<a name="l00349"></a>00349   <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00350"></a>00350 }
<a name="l00351"></a>00351 
<a name="l00352"></a>00352 
<a name="l00353"></a><a class="code" href="classKPlayer.html#4cb578100cf7596851ff3243d5e90ab0">00353</a> <span class="keywordtype">void</span> <a class="code" href="classKPlayer.html#4cb578100cf7596851ff3243d5e90ab0" title="Receives a message.">KPlayer::networkTransmission</a>(QDataStream &amp;stream,<span class="keywordtype">int</span> msgid,Q_UINT32 sender)
<a name="l00354"></a>00354 {
<a name="l00355"></a>00355   <span class="comment">//kdDebug(11001) &lt;&lt; k_funcinfo ": msgid=" &lt;&lt; msgid &lt;&lt; " sender=" &lt;&lt; sender &lt;&lt; " we are=" &lt;&lt; id() &lt;&lt; endl;</span>
<a name="l00356"></a>00356   <span class="comment">// PlayerProperties processed</span>
<a name="l00357"></a>00357   <span class="keywordtype">bool</span> issender;
<a name="l00358"></a>00358   <span class="keywordflow">if</span> (<a class="code" href="classKPlayer.html#377817feb7e53e5fe6deedc23f399b17" title="Query to which game the player belongs to.">game</a>())
<a name="l00359"></a>00359   {
<a name="l00360"></a>00360     issender=sender==<a class="code" href="classKPlayer.html#377817feb7e53e5fe6deedc23f399b17" title="Query to which game the player belongs to.">game</a>()-&gt;<a class="code" href="classKGameNetwork.html#505a8e205c26c166ad7903663e17b48a" title="The unique ID of this game.">gameId</a>();
<a name="l00361"></a>00361   }
<a name="l00362"></a>00362   <span class="keywordflow">else</span>
<a name="l00363"></a>00363   {
<a name="l00364"></a>00364     issender=<span class="keyword">true</span>;
<a name="l00365"></a>00365   }
<a name="l00366"></a>00366   <span class="keywordflow">if</span> (d-&gt;mProperties.processMessage(stream,msgid,issender))
<a name="l00367"></a>00367   {
<a name="l00368"></a>00368     return ;
<a name="l00369"></a>00369   }
<a name="l00370"></a>00370   <span class="keywordflow">switch</span>(msgid)
<a name="l00371"></a>00371   {
<a name="l00372"></a>00372     <span class="keywordflow">case</span> KGameMessage::IdPlayerInput:
<a name="l00373"></a>00373       {
<a name="l00374"></a>00374         kdDebug(11001) &lt;&lt; k_funcinfo &lt;&lt; <span class="stringliteral">": Got player move "</span>
<a name="l00375"></a>00375             &lt;&lt; <span class="stringliteral">"KPlayer (virtual) forwards it to the game object"</span> &lt;&lt; endl;
<a name="l00376"></a>00376         <a class="code" href="classKPlayer.html#41572b54137d6c26cd426a2d450c7afc" title="Forwards input to the game object.">forwardInput</a>(stream,<span class="keyword">false</span>);
<a name="l00377"></a>00377       }
<a name="l00378"></a>00378     <span class="keywordflow">break</span>;
<a name="l00379"></a>00379     <span class="keywordflow">default</span>:
<a name="l00380"></a>00380         emit <a class="code" href="classKPlayer.html#210346b1f5f4200a1f9dbb028dda9781" title="The player object got a message which was targeted at it but has no default method...">signalNetworkData</a>(msgid - KGameMessage::IdUser,
<a name="l00381"></a>00381             ((QBuffer*)stream.device())-&gt;readAll(),sender,<span class="keyword">this</span>);
<a name="l00382"></a>00382         kdDebug(11001) &lt;&lt; k_funcinfo &lt;&lt; <span class="stringliteral">": "</span>
<a name="l00383"></a>00383             &lt;&lt; <span class="stringliteral">"User data msgid "</span> &lt;&lt; msgid &lt;&lt; endl;
<a name="l00384"></a>00384     <span class="keywordflow">break</span>;
<a name="l00385"></a>00385   }
<a name="l00386"></a>00386 
<a name="l00387"></a>00387 }
<a name="l00388"></a>00388 
<a name="l00389"></a><a class="code" href="classKPlayer.html#d8f08f6b5ab55a9fcb0d3a94586f82f0">00389</a> <a class="code" href="classKGamePropertyBase.html" title="Base class of KGameProperty.">KGamePropertyBase</a>* <a class="code" href="classKPlayer.html#d8f08f6b5ab55a9fcb0d3a94586f82f0" title="Searches for a property of the player given its id.">KPlayer::findProperty</a>(<span class="keywordtype">int</span> <span class="keywordtype">id</span>)<span class="keyword"> const</span>
<a name="l00390"></a>00390 <span class="keyword"></span>{
<a name="l00391"></a>00391   <span class="keywordflow">return</span> d-&gt;mProperties.find(<span class="keywordtype">id</span>);
<a name="l00392"></a>00392 }
<a name="l00393"></a>00393 
<a name="l00394"></a><a class="code" href="classKPlayer.html#750164b9288ecdf1d916028a173a7e4b">00394</a> <span class="keywordtype">bool</span> <a class="code" href="classKPlayer.html#750164b9288ecdf1d916028a173a7e4b" title="Adds a property to a player.">KPlayer::addProperty</a>(<a class="code" href="classKGamePropertyBase.html" title="Base class of KGameProperty.">KGamePropertyBase</a>* data)
<a name="l00395"></a>00395 {
<a name="l00396"></a>00396   <span class="keywordflow">return</span> d-&gt;mProperties.addProperty(data);
<a name="l00397"></a>00397 }
<a name="l00398"></a>00398 
<a name="l00399"></a><a class="code" href="classKPlayer.html#106419f5d156a580895eb04b7bd4288f">00399</a> <span class="keywordtype">void</span> <a class="code" href="classKPlayer.html#106419f5d156a580895eb04b7bd4288f" title="Called by KGameProperty only! Internal function!">KPlayer::sendProperty</a>(<span class="keywordtype">int</span> msgid, QDataStream&amp; stream, <span class="keywordtype">bool</span>* sent)
<a name="l00400"></a>00400 {
<a name="l00401"></a>00401   <span class="keywordflow">if</span> (<a class="code" href="classKPlayer.html#377817feb7e53e5fe6deedc23f399b17" title="Query to which game the player belongs to.">game</a>())
<a name="l00402"></a>00402   {
<a name="l00403"></a>00403     <span class="keywordtype">bool</span> s = <a class="code" href="classKPlayer.html#377817feb7e53e5fe6deedc23f399b17" title="Query to which game the player belongs to.">game</a>()-&gt;<a class="code" href="classKGame.html#137420f5ead4a6957c988c87b7b02a08" title="This is called by KPlayer::sendProperty only! Internal function!">sendPlayerProperty</a>(msgid, stream, <span class="keywordtype">id</span>());
<a name="l00404"></a>00404     <span class="keywordflow">if</span> (s)
<a name="l00405"></a>00405     {
<a name="l00406"></a>00406       *sent = <span class="keyword">true</span>;
<a name="l00407"></a>00407     }
<a name="l00408"></a>00408   }
<a name="l00409"></a>00409 }
<a name="l00410"></a>00410 
<a name="l00411"></a><a class="code" href="classKPlayer.html#717226c69acbd6df2747d683565f9fda">00411</a> <span class="keywordtype">void</span> <a class="code" href="classKPlayer.html#717226c69acbd6df2747d683565f9fda" title="Called by KGameProperty only! Internal function!">KPlayer::emitSignal</a>(<a class="code" href="classKGamePropertyBase.html" title="Base class of KGameProperty.">KGamePropertyBase</a> *me)
<a name="l00412"></a>00412 {
<a name="l00413"></a>00413   <span class="comment">// Notify KGameIO (Process) for a new turn</span>
<a name="l00414"></a>00414   <span class="keywordflow">if</span> (me-&gt;<a class="code" href="classKGamePropertyBase.html#737382aa3e0194409c3b56fcc2ea15cb">id</a>()==KGamePropertyBase::IdTurn)
<a name="l00415"></a>00415   {
<a name="l00416"></a>00416     <span class="comment">//kdDebug(11001) &lt;&lt; k_funcinfo &lt;&lt; ": for KGamePropertyBase::IdTurn " &lt;&lt; endl;</span>
<a name="l00417"></a>00417     QPtrListIterator&lt;KGameIO&gt; it(mInputList);
<a name="l00418"></a>00418     <span class="keywordflow">while</span> (it.current())
<a name="l00419"></a>00419     {
<a name="l00420"></a>00420       it.current()-&gt;notifyTurn(mMyTurn.<a class="code" href="classKGameProperty.html#13c8d6333e09c220e9a327edeb79e074">value</a>());
<a name="l00421"></a>00421       ++it;
<a name="l00422"></a>00422     }
<a name="l00423"></a>00423   }
<a name="l00424"></a>00424   emit <a class="code" href="classKPlayer.html#37560785a930bc680e33147bdd2eaef6" title="This signal is emmited if a player property changes its value and the property is...">signalPropertyChanged</a>(me,<span class="keyword">this</span>);
<a name="l00425"></a>00425 }
<a name="l00426"></a>00426 
<a name="l00427"></a>00427 <span class="comment">// --------------------- DEBUG --------------------</span>
<a name="l00428"></a><a class="code" href="classKPlayer.html#f2e7e107afe0b587e345291b0daf9bad">00428</a> <span class="keywordtype">void</span> <a class="code" href="classKPlayer.html#f2e7e107afe0b587e345291b0daf9bad" title="Gives debug output of the game status.">KPlayer::Debug</a>()
<a name="l00429"></a>00429 {
<a name="l00430"></a>00430    kdDebug(11001) &lt;&lt; <span class="stringliteral">"------------------- KPLAYER -----------------------"</span> &lt;&lt; endl;
<a name="l00431"></a>00431    kdDebug(11001) &lt;&lt; <span class="stringliteral">"this:    "</span> &lt;&lt; <span class="keyword">this</span> &lt;&lt; endl;
<a name="l00432"></a>00432    kdDebug(11001) &lt;&lt; <span class="stringliteral">"rtti:    "</span> &lt;&lt; <a class="code" href="classKPlayer.html#b1127bc679ceac89a3150132a69ff701" title="The idendification of the player.">rtti</a>() &lt;&lt; endl;
<a name="l00433"></a>00433    kdDebug(11001) &lt;&lt; <span class="stringliteral">"id  :    "</span> &lt;&lt; <a class="code" href="classKPlayer.html#a1151863225396c0f96678bf3ca938ae" title="Returns the id of the player.">id</a>() &lt;&lt; endl;
<a name="l00434"></a>00434    kdDebug(11001) &lt;&lt; <span class="stringliteral">"Name :   "</span> &lt;&lt; <a class="code" href="classKPlayer.html#ec005101037bbdf9d445f69a5d6682c9">name</a>() &lt;&lt; endl;
<a name="l00435"></a>00435    kdDebug(11001) &lt;&lt; <span class="stringliteral">"Group:   "</span> &lt;&lt; <a class="code" href="classKPlayer.html#300571584f3fb5da37bf56b377131b03" title="Query the group the player belongs to.">group</a>() &lt;&lt; endl;
<a name="l00436"></a>00436    kdDebug(11001) &lt;&lt; <span class="stringliteral">"Async:   "</span> &lt;&lt; <a class="code" href="classKPlayer.html#ff79f9d54b46b8cb166735cebf93d13a" title="Query whether this player does asynchronous input.">asyncInput</a>() &lt;&lt; endl;
<a name="l00437"></a>00437    kdDebug(11001) &lt;&lt; <span class="stringliteral">"myTurn:  "</span> &lt;&lt; <a class="code" href="classKPlayer.html#20dcc5d9f7f2ada1a5dbcafa44ade404" title="is it my turn to go">myTurn</a>() &lt;&lt; endl;
<a name="l00438"></a>00438    kdDebug(11001) &lt;&lt; <span class="stringliteral">"Virtual: "</span> &lt;&lt; <a class="code" href="classKPlayer.html#dba8765b66df59bf09bb3db3d48e7423" title="Is this player a virtual player, ie is it created by mirroring a real player from...">isVirtual</a>() &lt;&lt; endl;
<a name="l00439"></a>00439    kdDebug(11001) &lt;&lt; <span class="stringliteral">"Active:  "</span> &lt;&lt; <a class="code" href="classKPlayer.html#06b52c8144adfddd8c27aef72829f74c" title="Is this player an active player.">isActive</a>() &lt;&lt; endl;
<a name="l00440"></a>00440    kdDebug(11001) &lt;&lt; <span class="stringliteral">"Priority:"</span> &lt;&lt; <a class="code" href="classKPlayer.html#ce1da9fc9f515e7ccaa28e3a2cad33a5" title="Returns whether this player can be replaced by a network connection player.">networkPriority</a>() &lt;&lt; endl;
<a name="l00441"></a>00441    kdDebug(11001) &lt;&lt; <span class="stringliteral">"Game   : "</span> &lt;&lt; <a class="code" href="classKPlayer.html#377817feb7e53e5fe6deedc23f399b17" title="Query to which game the player belongs to.">game</a>() &lt;&lt; endl;
<a name="l00442"></a>00442    kdDebug(11001) &lt;&lt; <span class="stringliteral">"#IOs:    "</span> &lt;&lt; mInputList.count() &lt;&lt; endl;
<a name="l00443"></a>00443    kdDebug(11001) &lt;&lt; <span class="stringliteral">"---------------------------------------------------"</span> &lt;&lt; endl;
<a name="l00444"></a>00444 }
<a name="l00445"></a>00445 
<a name="l00446"></a>00446 <span class="preprocessor">#include "kplayer.moc"</span>
</pre></div></div>
    </div></div>


      </td>
  </tr>
  <tr>
    <td valign="top" id="leftmenu" width="25%">
      <a name="navigation"></a>
      <div class="menu_box"><h2>libkdegames</h2>
<div class="nav_list">
<ul><li><a href="index.html">Main Page</a></li><li><a href="hierarchy.html">Class Hierarchy</a></li><li><a href="classes.html">Alphabetical List</a></li><li><a href="annotated.html">Class List</a></li><li><a href="files.html">File List</a></li><li><a href="functions.html">Class Members</a></li><li><a href="pages.html">Related Pages</a></li></ul>
<!--
<h2>Class Picker</h2>
<div style="text-align: center;">
<form name="guideform">
<select name="guidelinks" style="width:100%;" onChange="window.location=document.guideform.guidelinks.options[document.guideform.guidelinks.selectedIndex].value">
<option value="annotated.html">-- Choose --</option>
  <option value="classKCanvasRootPixmap.html">kcanvasrootpixmap</option>,  <option value="classKCardDialog.html">kcarddialog</option>,  <option value="classKChat.html">kchat</option>,  <option value="classKChatBase.html">kchatbase</option>,  <option value="classKChatBaseText.html">kchatbasetext</option>,  <option value="classKExtHighscore_1_1Item.html">kexthighscore::item</option>,  <option value="classKExtHighscore_1_1ItemArray.html">kexthighscore::itemarray</option>,  <option value="classKExtHighscore_1_1Manager.html">kexthighscore::manager</option>,  <option value="classKExtHighscore_1_1MultiplayerScores.html">kexthighscore::multiplayerscores</option>,  <option value="classKExtHighscore_1_1Score.html">kexthighscore::score</option>,  <option value="classKGame.html">kgame</option>,  <option value="classKGameChat.html">kgamechat</option>,  <option value="classKGameComputerIO.html">kgamecomputerio</option>,  <option value="classKGameConnectDialog.html">kgameconnectdialog</option>,  <option value="classKGameDialog.html">kgamedialog</option>,  <option value="classKGameDialogChatConfig.html">kgamedialogchatconfig</option>,  <option value="classKGameDialogConfig.html">kgamedialogconfig</option>,  <option value="classKGameErrorDialog.html">kgameerrordialog</option>,  <option value="classKGameErrorMessageDialog.html">kgameerrormessagedialog</option>,  <option value="classKGameIO.html">kgameio</option>,  <option value="classKGameKeyIO.html">kgamekeyio</option>,  <option value="classKGameLCD.html">kgamelcd</option>,  <option value="classKGameLCDClock.html">kgamelcdclock</option>,  <option value="classKGameLCDList.html">kgamelcdlist</option>,  <option value="classKGameMisc.html">kgamemisc</option>,  <option value="classKGameMouseIO.html">kgamemouseio</option>,  <option value="classKGameNetwork.html">kgamenetwork</option>,  <option value="classKGameProcess.html">kgameprocess</option>,  <option value="classKGameProcessIO.html">kgameprocessio</option>,  <option value="classKGameProgress.html">kgameprogress</option>,  <option value="classKGameProperty.html">kgameproperty</option>,  <option value="classKGamePropertyBase.html">kgamepropertybase</option>,  <option value="classKGamePropertyHandler.html">kgamepropertyhandler</option>,  <option value="classKGameSequence.html">kgamesequence</option>,  <option value="classKGrid2D_1_1Generic.html">kgrid2d::generic</option>,  <option value="classKGrid2D_1_1Hexagonal.html">kgrid2d::hexagonal</option>,  <option value="classKGrid2D_1_1HexagonalBase.html">kgrid2d::hexagonalbase</option>,  <option value="classKGrid2D_1_1Square.html">kgrid2d::square</option>,  <option value="classKGrid2D_1_1SquareBase.html">kgrid2d::squarebase</option>,  <option value="classKHighscore.html">khighscore</option>,  <option value="classKMessageClient.html">kmessageclient</option>,  <option value="classKMessageDirect.html">kmessagedirect</option>,  <option value="classKMessageIO.html">kmessageio</option>,  <option value="classKMessageServer.html">kmessageserver</option>,  <option value="classKMessageServerSocket.html">kmessageserversocket</option>,  <option value="classKMessageSocket.html">kmessagesocket</option>,  <option value="classKPlayer.html">kplayer</option>,  <option value="classKScoreDialog.html">kscoredialog</option>,  <option value="classKStdGameAction.html">kstdgameaction</option>,
</select>
</form>
</div>
-->
</div></div>
<div class="menu_box"><h2>API Dox</h2>
<div class="nav_list">
<ul>
<li><a href="../../libkdegames/html/index.html">libkdegames</a></li>
</ul></div></div>


        </td>
</tr>
</table>

<span class="doNotDisplay">
  <a href="http://www.kde.org/" accesskey="8">KDE Home</a> |
  <a href="http://accessibility.kde.org/" accesskey="9">KDE Accessibility Home</a> |
  <a href="http://www.kde.org/media/accesskeys.php" accesskey="0">Description of Access Keys</a>
</span>


<div style="height: 8px"></div>

<div id="footer">
  <div id="footer_left">
    Maintained by <a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;groo&#116;&#64;kde&#46;or&#x67;">Adriaan de Groot</a>
and
<a href="&#109;a&#105;&#108;&#116;&#111;&#58;w&#105;nter&#64;kde&#46;or&#x67">Allen Winter</a>.
<br/>
    KDE and K Desktop Environment are trademarks of <a href="http://www.kde.org/areas/kde-ev/" title="Homepage of the KDE non-profit Organization">KDE e.V.</a> |
    <a href="http://www.kde.org/contact/impressum.php">Legal</a>
  </div>
  <div id="footer_right"><img src="/media/images/footer_right.png" style="margin: 0px" alt="" /></div>
</div>

<!--
WARNING: DO NOT SEND MAIL TO THE FOLLOWING EMAIL ADDRESS! YOU WILL
BE BLOCKED INSTANTLY AND PERMANENTLY!
<a href="mailto:aaaatrap-425acc3b5374943f@kde.org">Block me</a>
WARNING END
-->

</body>
</html>