summaryrefslogtreecommitdiffstats
path: root/libkdegames/kgame/kgame.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libkdegames/kgame/kgame.cpp')
-rw-r--r--libkdegames/kgame/kgame.cpp122
1 files changed, 61 insertions, 61 deletions
diff --git a/libkdegames/kgame/kgame.cpp b/libkdegames/kgame/kgame.cpp
index 101dbfcc..ff215837 100644
--- a/libkdegames/kgame/kgame.cpp
+++ b/libkdegames/kgame/kgame.cpp
@@ -36,10 +36,10 @@
#include <stdio.h>
#include <assert.h>
-#include <qbuffer.h>
-#include <qtimer.h>
-#include <qptrqueue.h>
-#include <qfile.h>
+#include <tqbuffer.h>
+#include <tqtimer.h>
+#include <tqptrqueue.h>
+#include <tqfile.h>
#include <klocale.h>
#include <krandomsequence.h>
@@ -60,7 +60,7 @@ public:
}
int mUniquePlayerNumber;
- QPtrQueue<KPlayer> mAddPlayerList;// this is a list of to-be-added players. See addPlayer() docu
+ TQPtrQueue<KPlayer> mAddPlayerList;// this is a list of to-be-added players. See addPlayer() docu
KRandomSequence* mRandom;
KGame::GamePolicy mPolicy;
KGameSequence* mGameSequence;
@@ -76,12 +76,12 @@ public:
KGamePropertyInt mMaxPlayer;
KGamePropertyUInt mMinPlayer;
KGamePropertyInt mGameStatus; // Game running?
- QValueList<int> mInactiveIdList;
+ TQValueList<int> mInactiveIdList;
};
// ------------------- GAME CLASS --------------------------
-KGame::KGame(int cookie,QObject* parent) : KGameNetwork(cookie,parent)
+KGame::KGame(int cookie,TQObject* parent) : KGameNetwork(cookie,parent)
{
kdDebug(11001) << k_funcinfo << " - " << this << ", sizeof(KGame)=" << sizeof(KGame) << endl;
d = new KGamePrivate;
@@ -89,8 +89,8 @@ KGame::KGame(int cookie,QObject* parent) : KGameNetwork(cookie,parent)
d->mProperties = new KGamePropertyHandler(this);
d->mProperties->registerHandler(KGameMessage::IdGameProperty,
- this,SLOT(sendProperty(int, QDataStream&, bool* )),
- SLOT(emitSignal(KGamePropertyBase *)));
+ this,TQT_SLOT(sendProperty(int, TQDataStream&, bool* )),
+ TQT_SLOT(emitSignal(KGamePropertyBase *)));
d->mMaxPlayer.registerData(KGamePropertyBase::IdMaxPlayer, this, i18n("MaxPlayers"));
d->mMaxPlayer.setLocal(-1); // Infinite
d->mMinPlayer.registerData(KGamePropertyBase::IdMinPlayer, this, i18n("MinPlayers"));
@@ -101,20 +101,20 @@ KGame::KGame(int cookie,QObject* parent) : KGameNetwork(cookie,parent)
d->mRandom = new KRandomSequence;
d->mRandom->setSeed(0);
- connect(this, SIGNAL(signalClientConnected(Q_UINT32)),
- this, SLOT(slotClientConnected(Q_UINT32)));
- connect(this, SIGNAL(signalClientDisconnected(Q_UINT32,bool)),
- this, SLOT(slotClientDisconnected(Q_UINT32,bool)));
- connect(this, SIGNAL(signalConnectionBroken()),
- this, SLOT(slotServerDisconnected()));
+ connect(this, TQT_SIGNAL(signalClientConnected(Q_UINT32)),
+ this, TQT_SLOT(slotClientConnected(Q_UINT32)));
+ connect(this, TQT_SIGNAL(signalClientDisconnected(Q_UINT32,bool)),
+ this, TQT_SLOT(slotClientDisconnected(Q_UINT32,bool)));
+ connect(this, TQT_SIGNAL(signalConnectionBroken()),
+ this, TQT_SLOT(slotServerDisconnected()));
setGameSequence(new KGameSequence());
// BL: FIXME This signal does no longer exist. When we are merging
// MH: super....and how do I find out about the lost conenction now?
// KGame and KGameNetwork, this could be improved!
-// connect(this,SIGNAL(signalConnectionLost(KGameClient *)),
-// this,SLOT(slotConnectionLost(KGameClient *)));
+// connect(this,TQT_SIGNAL(signalConnectionLost(KGameClient *)),
+// this,TQT_SLOT(slotConnectionLost(KGameClient *)));
}
KGame::~KGame()
@@ -159,27 +159,27 @@ void KGame::deleteInactivePlayers()
}
}
-bool KGame::load(QString filename,bool reset)
+bool KGame::load(TQString filename,bool reset)
{
if (filename.isNull())
{
return false;
}
- QFile f(filename);
+ TQFile f(filename);
if (!f.open(IO_ReadOnly))
{
return false;
}
- QDataStream s( &f );
+ TQDataStream s( &f );
load(s,reset);
f.close();
return true;
}
-bool KGame::load(QDataStream &stream,bool reset)
+bool KGame::load(TQDataStream &stream,bool reset)
{ return loadgame(stream, false,reset); }
-bool KGame::loadgame(QDataStream &stream, bool network,bool resetgame)
+bool KGame::loadgame(TQDataStream &stream, bool network,bool resetgame)
{
// Load Game Data
@@ -264,27 +264,27 @@ bool KGame::loadgame(QDataStream &stream, bool network,bool resetgame)
return true;
}
-bool KGame::save(QString filename,bool saveplayers)
+bool KGame::save(TQString filename,bool saveplayers)
{
if (filename.isNull())
{
return false;
}
- QFile f(filename);
+ TQFile f(filename);
if (!f.open(IO_WriteOnly))
{
return false;
}
- QDataStream s( &f );
+ TQDataStream s( &f );
save(s,saveplayers);
f.close();
return true;
}
-bool KGame::save(QDataStream &stream,bool saveplayers)
+bool KGame::save(TQDataStream &stream,bool saveplayers)
{ return savegame(stream, false,saveplayers); }
-bool KGame::savegame(QDataStream &stream,bool /*network*/,bool saveplayers)
+bool KGame::savegame(TQDataStream &stream,bool /*network*/,bool saveplayers)
{
// Save Game Data
@@ -320,7 +320,7 @@ bool KGame::savegame(QDataStream &stream,bool /*network*/,bool saveplayers)
return true;
}
-void KGame::savePlayer(QDataStream &stream,KPlayer* p)
+void KGame::savePlayer(TQDataStream &stream,KPlayer* p)
{
// this could be in KGameMessage as well
stream << (Q_INT32)p->rtti();
@@ -329,7 +329,7 @@ void KGame::savePlayer(QDataStream &stream,KPlayer* p)
p->save(stream);
}
-void KGame::savePlayers(QDataStream &stream, KGamePlayerList *list)
+void KGame::savePlayers(TQDataStream &stream, KGamePlayerList *list)
{
if (!list)
{
@@ -351,7 +351,7 @@ KPlayer *KGame::createPlayer(int /*rtti*/,int /*io*/,bool /*isvirtual*/)
kdWarning(11001) << " No user defined player created. Creating default KPlayer. This crashes if you have overwritten KPlayer!!!! " << endl;
return new KPlayer;
}
-KPlayer *KGame::loadPlayer(QDataStream& stream,bool isvirtual)
+KPlayer *KGame::loadPlayer(TQDataStream& stream,bool isvirtual)
{
Q_INT32 rtti,id,iovalue;
stream >> rtti >> id >> iovalue;
@@ -385,14 +385,14 @@ KPlayer *KGame::loadPlayer(QDataStream& stream,bool isvirtual)
KPlayer * KGame::findPlayer(Q_UINT32 id) const
{
- for (QPtrListIterator<KPlayer> it(d->mPlayerList); it.current(); ++it)
+ for (TQPtrListIterator<KPlayer> it(d->mPlayerList); it.current(); ++it)
{
if (it.current()->id() == id)
{
return it.current();
}
}
- for (QPtrListIterator<KPlayer> it(d->mInactivePlayerList); it.current(); ++it)
+ for (TQPtrListIterator<KPlayer> it(d->mInactivePlayerList); it.current(); ++it)
{
if (it.current()->id() == id)
{
@@ -438,8 +438,8 @@ void KGame::addPlayer(KPlayer* newplayer)
kdDebug(11001) << k_funcinfo << "player " << newplayer << " already has an id: " << newplayer->id() << endl;
}
- QByteArray buffer;
- QDataStream stream(buffer,IO_WriteOnly);
+ TQByteArray buffer;
+ TQDataStream stream(buffer,IO_WriteOnly);
// We distinguis here what policy we have
if (policy()==PolicyLocal || policy()==PolicyDirty)
{
@@ -706,7 +706,7 @@ KRandomSequence* KGame::random() const
{ return d->mRandom; }
-bool KGame::sendPlayerInput(QDataStream &msg, KPlayer *player, Q_UINT32 sender)
+bool KGame::sendPlayerInput(TQDataStream &msg, KPlayer *player, Q_UINT32 sender)
{
if (!player)
{
@@ -724,7 +724,7 @@ bool KGame::sendPlayerInput(QDataStream &msg, KPlayer *player, Q_UINT32 sender)
return true;
}
-bool KGame::systemPlayerInput(QDataStream &msg, KPlayer *player, Q_UINT32 sender)
+bool KGame::systemPlayerInput(TQDataStream &msg, KPlayer *player, Q_UINT32 sender)
{
if (!player)
{
@@ -780,7 +780,7 @@ KPlayer * KGame::playerInputFinished(KPlayer *player)
player->setTurn(false); // in turn based games we have to switch off input now
if (gameSequence())
{
- QTimer::singleShot(0,this,SLOT(prepareNext()));
+ TQTimer::singleShot(0,this,TQT_SLOT(prepareNext()));
}
}
return player;
@@ -840,7 +840,7 @@ void KGame::setGameStatus(int status)
d->mGameStatus = status;
}
-void KGame::networkTransmission(QDataStream &stream, int msgid, Q_UINT32 receiver, Q_UINT32 sender, Q_UINT32 /*clientID*/)
+void KGame::networkTransmission(TQDataStream &stream, int msgid, Q_UINT32 receiver, Q_UINT32 sender, Q_UINT32 /*clientID*/)
{//clientID is unused
// message targets a playerobject. If we find it we forward the message to the
// player. Otherwise we proceed here and hope the best that the user processes
@@ -1033,7 +1033,7 @@ void KGame::networkTransmission(QDataStream &stream, int msgid, Q_UINT32 receive
<< endl;
}
kdDebug(11001) << k_funcinfo << ": User data msgid " << msgid << endl;
- emit signalNetworkData(msgid - KGameMessage::IdUser,((QBuffer*)stream.device())->readAll(),receiver,sender);
+ emit signalNetworkData(msgid - KGameMessage::IdUser,((TQBuffer*)stream.device())->readAll(),receiver,sender);
}
break;
}
@@ -1043,14 +1043,14 @@ void KGame::networkTransmission(QDataStream &stream, int msgid, Q_UINT32 receive
// called by the IdSetupGameContinue Message - MASTER SIDE
// Here the master needs to decide which players can take part at the game
// and which will be deactivated
-void KGame::setupGameContinue(QDataStream& stream, Q_UINT32 sender)
+void KGame::setupGameContinue(TQDataStream& stream, Q_UINT32 sender)
{
KPlayer *player;
Q_INT32 cnt;
int i;
stream >> cnt;
- QValueList<int> inactivateIds;
+ TQValueList<int> inactivateIds;
KGamePlayerList newPlayerList;
newPlayerList.setAutoDelete(true);
@@ -1135,7 +1135,7 @@ void KGame::setupGameContinue(QDataStream& stream, Q_UINT32 sender)
kdDebug(11001) << "Alltogether deactivated " << inactivateIds.count() << " players" << endl;
- QValueList<int>::Iterator it;
+ TQValueList<int>::Iterator it;
for ( it = inactivateIds.begin(); it != inactivateIds.end(); ++it )
{
int pid=*it;
@@ -1143,7 +1143,7 @@ void KGame::setupGameContinue(QDataStream& stream, Q_UINT32 sender)
}
// Now deactivate the network players from the inactivateId list
- //QValueList<int>::Iterator it;
+ //TQValueList<int>::Iterator it;
for ( it = inactivateIds.begin(); it != inactivateIds.end(); ++it )
{
int pid=*it;
@@ -1182,8 +1182,8 @@ void KGame::setupGameContinue(QDataStream& stream, Q_UINT32 sender)
}
// Save the game over the network
- QByteArray bufferS;
- QDataStream streamS(bufferS,IO_WriteOnly);
+ TQByteArray bufferS;
+ TQDataStream streamS(bufferS,IO_WriteOnly);
// Save game over netowrk and save players
savegame(streamS,true,true);
sendSystemMessage(streamS,KGameMessage::IdGameLoad,sender);
@@ -1197,8 +1197,8 @@ void KGame::setupGameContinue(QDataStream& stream, Q_UINT32 sender)
// Client needs to prepare for network transfer
void KGame::setupGame(Q_UINT32 sender)
{
- QByteArray bufferS;
- QDataStream streamS(bufferS,IO_WriteOnly);
+ TQByteArray bufferS;
+ TQDataStream streamS(bufferS,IO_WriteOnly);
// Deactivate all players
KGamePlayerList mTmpList(d->mPlayerList); // we need copy otherwise the removal crashes
@@ -1207,7 +1207,7 @@ void KGame::setupGame(Q_UINT32 sender)
streamS << cnt;
- QPtrListIterator<KPlayer> it(mTmpList);
+ TQPtrListIterator<KPlayer> it(mTmpList);
KPlayer *player;
while (it.current())
{
@@ -1356,7 +1356,7 @@ void KGame::slotClientDisconnected(Q_UINT32 clientID,bool /*broken*/) // server
// TODO remove players from removed game
for (unsigned int idx=0;idx<d->mInactiveIdList.count();idx++)
{
- QValueList<int>::Iterator it1 = d->mInactiveIdList.at(idx);
+ TQValueList<int>::Iterator it1 = d->mInactiveIdList.at(idx);
player = findPlayer(*it1);
if (((int)playerCount() < maxPlayers() || maxPlayers() < 0) && player && KGameMessage::rawGameId(*it1) != clientID)
{
@@ -1382,8 +1382,8 @@ void KGame::negotiateNetworkGame(Q_UINT32 clientID)
return ;
}
- QByteArray buffer;
- QDataStream streamGS(buffer,IO_WriteOnly);
+ TQByteArray buffer;
+ TQDataStream streamGS(buffer,IO_WriteOnly);
// write Game setup specific data
//streamGS << (Q_INT32)maxPlayers();
@@ -1396,7 +1396,7 @@ void KGame::negotiateNetworkGame(Q_UINT32 clientID)
sendSystemMessage(streamGS, KGameMessage::IdSetupGame, clientID);
}
-bool KGame::sendGroupMessage(const QByteArray &msg, int msgid, Q_UINT32 sender, const QString& group)
+bool KGame::sendGroupMessage(const TQByteArray &msg, int msgid, Q_UINT32 sender, const TQString& group)
{
// AB: group must not be i18n'ed!! we should better use an id for group and use
// a groupName() for the name // FIXME
@@ -1411,13 +1411,13 @@ bool KGame::sendGroupMessage(const QByteArray &msg, int msgid, Q_UINT32 sender,
return true;
}
-bool KGame::sendGroupMessage(const QDataStream &msg, int msgid, Q_UINT32 sender, const QString& group)
-{ return sendGroupMessage(((QBuffer*)msg.device())->buffer(), msgid, sender, group); }
+bool KGame::sendGroupMessage(const TQDataStream &msg, int msgid, Q_UINT32 sender, const TQString& group)
+{ return sendGroupMessage(((TQBuffer*)msg.device())->buffer(), msgid, sender, group); }
-bool KGame::sendGroupMessage(const QString& msg, int msgid, Q_UINT32 sender, const QString& group)
+bool KGame::sendGroupMessage(const TQString& msg, int msgid, Q_UINT32 sender, const TQString& group)
{
- QByteArray buffer;
- QDataStream stream(buffer, IO_WriteOnly);
+ TQByteArray buffer;
+ TQDataStream stream(buffer, IO_WriteOnly);
stream << msg;
return sendGroupMessage(stream, msgid, sender, group);
}
@@ -1425,10 +1425,10 @@ bool KGame::sendGroupMessage(const QString& msg, int msgid, Q_UINT32 sender, con
bool KGame::addProperty(KGamePropertyBase* data)
{ return dataHandler()->addProperty(data); }
-bool KGame::sendPlayerProperty(int msgid, QDataStream& s, Q_UINT32 playerId)
+bool KGame::sendPlayerProperty(int msgid, TQDataStream& s, Q_UINT32 playerId)
{ return sendSystemMessage(s, msgid, playerId); }
-void KGame::sendProperty(int msgid, QDataStream& stream, bool* sent)
+void KGame::sendProperty(int msgid, TQDataStream& stream, bool* sent)
{
bool s = sendSystemMessage(stream, msgid);
if (s)
@@ -1459,11 +1459,11 @@ void KGame::setPolicy(GamePolicy p,bool recursive)
dataHandler()->setPolicy((KGamePropertyBase::PropertyPolicy)p,false);
// Set all KPLayer (active or inactive) property policy
- for (QPtrListIterator<KPlayer> it(d->mPlayerList); it.current(); ++it)
+ for (TQPtrListIterator<KPlayer> it(d->mPlayerList); it.current(); ++it)
{
it.current()->dataHandler()->setPolicy((KGamePropertyBase::PropertyPolicy)p,false);
}
- for (QPtrListIterator<KPlayer> it(d->mInactivePlayerList); it.current(); ++it)
+ for (TQPtrListIterator<KPlayer> it(d->mInactivePlayerList); it.current(); ++it)
{
it.current()->dataHandler()->setPolicy((KGamePropertyBase::PropertyPolicy)p,false);
}