summaryrefslogtreecommitdiffstats
path: root/libkdegames/kgame/kgame.cpp
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-06-11 04:58:26 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-06-11 04:58:26 +0000
commit838baf3f99ec5ab81b063eb5449a3381d860f377 (patch)
treedd31abcfde08ca92e4623b8f50b3d762a87c997a /libkdegames/kgame/kgame.cpp
parent2bf598bafa22fac4126fc8842df6b0119aadc0e9 (diff)
downloadtdegames-838baf3f99ec5ab81b063eb5449a3381d860f377.tar.gz
tdegames-838baf3f99ec5ab81b063eb5449a3381d860f377.zip
TQt4 port kdegames
This enables compilation under both Qt3 and Qt4 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdegames@1236074 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'libkdegames/kgame/kgame.cpp')
-rw-r--r--libkdegames/kgame/kgame.cpp110
1 files changed, 55 insertions, 55 deletions
diff --git a/libkdegames/kgame/kgame.cpp b/libkdegames/kgame/kgame.cpp
index ff215837..42a21580 100644
--- a/libkdegames/kgame/kgame.cpp
+++ b/libkdegames/kgame/kgame.cpp
@@ -75,13 +75,13 @@ public:
//KGamePropertys
KGamePropertyInt mMaxPlayer;
KGamePropertyUInt mMinPlayer;
- KGamePropertyInt mGameStatus; // Game running?
+ KGamePropertyInt mGametqStatus; // Game running?
TQValueList<int> mInactiveIdList;
};
// ------------------- GAME CLASS --------------------------
-KGame::KGame(int cookie,TQObject* parent) : KGameNetwork(cookie,parent)
+KGame::KGame(int cookie,TQObject* tqparent) : KGameNetwork(cookie,tqparent)
{
kdDebug(11001) << k_funcinfo << " - " << this << ", sizeof(KGame)=" << sizeof(KGame) << endl;
d = new KGamePrivate;
@@ -95,16 +95,16 @@ KGame::KGame(int cookie,TQObject* parent) : KGameNetwork(cookie,parent)
d->mMaxPlayer.setLocal(-1); // Infinite
d->mMinPlayer.registerData(KGamePropertyBase::IdMinPlayer, this, i18n("MinPlayers"));
d->mMinPlayer.setLocal(0); // Always ok
- d->mGameStatus.registerData(KGamePropertyBase::IdGameStatus, this, i18n("GameStatus"));
- d->mGameStatus.setLocal(Init);
+ d->mGametqStatus.registerData(KGamePropertyBase::IdGametqStatus, this, i18n("GametqStatus"));
+ d->mGametqStatus.setLocal(Init);
// d->mUniquePlayerNumber = 0;
d->mRandom = new KRandomSequence;
d->mRandom->setSeed(0);
- 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(signalClientConnected(TQ_UINT32)),
+ this, TQT_SLOT(slotClientConnected(TQ_UINT32)));
+ connect(this, TQT_SIGNAL(signalClientDisconnected(TQ_UINT32,bool)),
+ this, TQT_SLOT(slotClientDisconnected(TQ_UINT32,bool)));
connect(this, TQT_SIGNAL(signalConnectionBroken()),
this, TQT_SLOT(slotServerDisconnected()));
@@ -184,7 +184,7 @@ bool KGame::loadgame(TQDataStream &stream, bool network,bool resetgame)
// Load Game Data
// internal data
- Q_INT32 c;
+ TQ_INT32 c;
stream >> c; // cookie
if (c!=cookie())
@@ -241,7 +241,7 @@ bool KGame::loadgame(TQDataStream &stream, bool network,bool resetgame)
systemAddPlayer(newplayer);
}
- Q_INT16 cookie;
+ TQ_INT16 cookie;
stream >> cookie;
if (cookie==KGAME_LOAD_COOKIE) {
kdDebug(11001) << " Game loaded propertly"<<endl;
@@ -289,7 +289,7 @@ bool KGame::savegame(TQDataStream &stream,bool /*network*/,bool saveplayers)
// Save Game Data
// internal variables
- Q_INT32 c=cookie();
+ TQ_INT32 c=cookie();
stream << c;
uint p=(uint)policy();
@@ -314,7 +314,7 @@ bool KGame::savegame(TQDataStream &stream,bool /*network*/,bool saveplayers)
stream << (uint)0; // no players saved
}
- stream << (Q_INT16)KGAME_LOAD_COOKIE;
+ stream << (TQ_INT16)KGAME_LOAD_COOKIE;
emit signalSave(stream);
return true;
@@ -323,9 +323,9 @@ bool KGame::savegame(TQDataStream &stream,bool /*network*/,bool saveplayers)
void KGame::savePlayer(TQDataStream &stream,KPlayer* p)
{
// this could be in KGameMessage as well
- stream << (Q_INT32)p->rtti();
- stream << (Q_INT32)p->id();
- stream << (Q_INT32)p->calcIOValue();
+ stream << (TQ_INT32)p->rtti();
+ stream << (TQ_INT32)p->id();
+ stream << (TQ_INT32)p->calcIOValue();
p->save(stream);
}
@@ -336,7 +336,7 @@ void KGame::savePlayers(TQDataStream &stream, KGamePlayerList *list)
list=playerList();
}
- Q_INT32 cnt=list->count();
+ TQ_INT32 cnt=list->count();
kdDebug(11001) << "Saving KGame " << cnt << " KPlayer objects " << endl;
stream << cnt;
KPlayer *player;
@@ -353,7 +353,7 @@ KPlayer *KGame::createPlayer(int /*rtti*/,int /*io*/,bool /*isvirtual*/)
}
KPlayer *KGame::loadPlayer(TQDataStream& stream,bool isvirtual)
{
- Q_INT32 rtti,id,iovalue;
+ TQ_INT32 rtti,id,iovalue;
stream >> rtti >> id >> iovalue;
KPlayer *newplayer=findPlayer(id);
if (!newplayer)
@@ -383,7 +383,7 @@ KPlayer *KGame::loadPlayer(TQDataStream& stream,bool isvirtual)
// ----------------- Player handling -----------------------
-KPlayer * KGame::findPlayer(Q_UINT32 id) const
+KPlayer * KGame::findPlayer(TQ_UINT32 id) const
{
for (TQPtrListIterator<KPlayer> it(d->mPlayerList); it.current(); ++it)
{
@@ -507,7 +507,7 @@ void KGame::playerDeleted(KPlayer *player)
}
}
-bool KGame::removePlayer(KPlayer * player, Q_UINT32 receiver)
+bool KGame::removePlayer(KPlayer * player, TQ_UINT32 receiver)
{//transmit to all clients, or to receiver only
if (!player)
{
@@ -542,10 +542,10 @@ void KGame::systemRemovePlayer(KPlayer* player,bool deleteit)
kdWarning(11001) << "player " << player << "(" << player->id() << ") Could not be found!" << endl;
}
- if (gameStatus()==(int)Run && playerCount()<minPlayers())
+ if (gametqStatus()==(int)Run && playerCount()<minPlayers())
{
kdWarning(11001) << k_funcinfo ": not enough players, PAUSING game\n" << endl;
- setGameStatus(Pause);
+ setGametqStatus(Pause);
}
}
@@ -680,11 +680,11 @@ int KGame::maxPlayers() const
uint KGame::playerCount() const
{ return d->mPlayerList.count(); }
-int KGame::gameStatus() const
-{ return d->mGameStatus.value(); }
+int KGame::gametqStatus() const
+{ return d->mGametqStatus.value(); }
bool KGame::isRunning() const
-{ return d->mGameStatus.value() == Run; }
+{ return d->mGametqStatus.value() == Run; }
KGamePropertyHandler* KGame::dataHandler() const
{ return d->mProperties; }
@@ -706,7 +706,7 @@ KRandomSequence* KGame::random() const
{ return d->mRandom; }
-bool KGame::sendPlayerInput(TQDataStream &msg, KPlayer *player, Q_UINT32 sender)
+bool KGame::sendPlayerInput(TQDataStream &msg, KPlayer *player, TQ_UINT32 sender)
{
if (!player)
{
@@ -724,7 +724,7 @@ bool KGame::sendPlayerInput(TQDataStream &msg, KPlayer *player, Q_UINT32 sender)
return true;
}
-bool KGame::systemPlayerInput(TQDataStream &msg, KPlayer *player, Q_UINT32 sender)
+bool KGame::systemPlayerInput(TQDataStream &msg, KPlayer *player, TQ_UINT32 sender)
{
if (!player)
{
@@ -772,7 +772,7 @@ KPlayer * KGame::playerInputFinished(KPlayer *player)
{
player->setTurn(false);
}
- setGameStatus(End);
+ setGametqStatus(End);
emit signalGameOver(gameOver,player,this);
}
else if (!player->asyncInput())
@@ -829,7 +829,7 @@ KPlayer *KGame::nextPlayer(KPlayer *last,bool exclusive)
return 0;
}
-void KGame::setGameStatus(int status)
+void KGame::setGametqStatus(int status)
{
kdDebug(11001) << k_funcinfo << ": GAMESTATUS CHANGED to" << status << endl;
if (status==(int)Run && playerCount()<minPlayers())
@@ -837,10 +837,10 @@ void KGame::setGameStatus(int status)
kdDebug(11001) << k_funcinfo << ": not enough players, pausing game\n" << endl;
status=Pause;
}
- d->mGameStatus = status;
+ d->mGametqStatus = status;
}
-void KGame::networkTransmission(TQDataStream &stream, int msgid, Q_UINT32 receiver, Q_UINT32 sender, Q_UINT32 /*clientID*/)
+void KGame::networkTransmission(TQDataStream &stream, int msgid, TQ_UINT32 receiver, TQ_UINT32 sender, TQ_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
@@ -884,8 +884,8 @@ void KGame::networkTransmission(TQDataStream &stream, int msgid, Q_UINT32 receiv
{
case KGameMessage::IdSetupGame: // Client: First step in setup game
{
- Q_INT16 v;
- Q_INT32 c;
+ TQ_INT16 v;
+ TQ_INT32 c;
stream >> v >> c;
kdDebug(11001) << " ===================> (Client) " << k_funcinfo << ": Got IdSetupGame ================== " << endl;
kdDebug(11001) << "our game id is " << gameId() << " Lib version=" << v << " App Cookie=" << c << endl;
@@ -1043,10 +1043,10 @@ void KGame::networkTransmission(TQDataStream &stream, int msgid, Q_UINT32 receiv
// 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(TQDataStream& stream, Q_UINT32 sender)
+void KGame::setupGameContinue(TQDataStream& stream, TQ_UINT32 sender)
{
KPlayer *player;
- Q_INT32 cnt;
+ TQ_INT32 cnt;
int i;
stream >> cnt;
@@ -1093,7 +1093,7 @@ void KGame::setupGameContinue(TQDataStream& stream, Q_UINT32 sender)
for ( player=newPlayerList.first(); player != 0; player=newPlayerList.next() )
{
// Already in the list
- if (inactivateIds.find(player->id())!=inactivateIds.end())
+ if (inactivateIds.tqfind(player->id())!=inactivateIds.end())
{
continue;
}
@@ -1109,7 +1109,7 @@ void KGame::setupGameContinue(TQDataStream& stream, Q_UINT32 sender)
for ( player=d->mPlayerList.first(); player != 0; player=d->mPlayerList.next() )
{
// Already in the list
- if (inactivateIds.find(player->id())!=inactivateIds.end())
+ if (inactivateIds.tqfind(player->id())!=inactivateIds.end())
{
continue;
}
@@ -1171,9 +1171,9 @@ void KGame::setupGameContinue(TQDataStream& stream, Q_UINT32 sender)
// Now send out the player list which the client can activate
for ( player=newPlayerList.first(); player != 0; player=newPlayerList.next() )
{
- kdDebug(11001) << " newplayerlist contains " << player->id() << endl;
+ kdDebug(11001) << " newplayerlist tqcontains " << player->id() << endl;
// Only activate what is not in the list
- if (inactivateIds.find(player->id())!=inactivateIds.end())
+ if (inactivateIds.tqfind(player->id())!=inactivateIds.end())
{
continue;
}
@@ -1195,14 +1195,14 @@ void KGame::setupGameContinue(TQDataStream& stream, Q_UINT32 sender)
// called by the IdSetupGame Message - CLIENT SIDE
// Client needs to prepare for network transfer
-void KGame::setupGame(Q_UINT32 sender)
+void KGame::setupGame(TQ_UINT32 sender)
{
TQByteArray bufferS;
TQDataStream streamS(bufferS,IO_WriteOnly);
// Deactivate all players
KGamePlayerList mTmpList(d->mPlayerList); // we need copy otherwise the removal crashes
- Q_INT32 cnt=mTmpList.count();
+ TQ_INT32 cnt=mTmpList.count();
kdDebug(11001) << "Client: playerlistcount=" << d->mPlayerList.count() << " tmplistcout=" << cnt << endl;
streamS << cnt;
@@ -1244,14 +1244,14 @@ void KGame::Debug()
kdDebug(11001) << "------------------- KGAME -------------------------" << endl;
kdDebug(11001) << "this: " << this << endl;
kdDebug(11001) << "uniquePlayer " << d->mUniquePlayerNumber << endl;
- kdDebug(11001) << "gameStatus " << gameStatus() << endl;
+ kdDebug(11001) << "gametqStatus " << gametqStatus() << endl;
kdDebug(11001) << "MaxPlayers : " << maxPlayers() << endl;
kdDebug(11001) << "NoOfPlayers : " << playerCount() << endl;
kdDebug(11001) << "NoOfInactive: " << d->mInactivePlayerList.count() << endl;
kdDebug(11001) << "---------------------------------------------------" << endl;
}
-void KGame::slotClientConnected(Q_UINT32 clientID)
+void KGame::slotClientConnected(TQ_UINT32 clientID)
{
if (isAdmin())
{
@@ -1264,7 +1264,7 @@ void KGame::slotServerDisconnected() // Client side
kdDebug(11001) << "======= SERVER DISCONNECT ======="<<endl;
kdDebug(11001) << "+++ (CLIENT)++++++++" << k_funcinfo << ": our GameID="<<gameId() << endl;
- int oldgamestatus=gameStatus();
+ int oldgamestatus=gametqStatus();
KPlayer *player;
KGamePlayerList removeList;
@@ -1322,11 +1322,11 @@ void KGame::slotServerDisconnected() // Client side
emit signalClientLeftGame(0,oldgamestatus,this);
}
-void KGame::slotClientDisconnected(Q_UINT32 clientID,bool /*broken*/) // server side
+void KGame::slotClientDisconnected(TQ_UINT32 clientID,bool /*broken*/) // server side
{
kdDebug(11001) << "++++(SERVER)+++++++" << k_funcinfo << " clientId=" << clientID << endl;
- int oldgamestatus=gameStatus();
+ int oldgamestatus=gametqStatus();
KPlayer *player;
KGamePlayerList removeList;
@@ -1373,7 +1373,7 @@ void KGame::slotClientDisconnected(Q_UINT32 clientID,bool /*broken*/) // server
// we send the number of players (including type) as well as game status and
// properties to the client. After the initialization has been completed both
// clients should have the same status (ie players, properties, etc)
-void KGame::negotiateNetworkGame(Q_UINT32 clientID)
+void KGame::negotiateNetworkGame(TQ_UINT32 clientID)
{
kdDebug(11001) << "===========================" << k_funcinfo << ": clientID=" << clientID << " =========================== "<< endl;
if (!isAdmin())
@@ -1386,17 +1386,17 @@ void KGame::negotiateNetworkGame(Q_UINT32 clientID)
TQDataStream streamGS(buffer,IO_WriteOnly);
// write Game setup specific data
- //streamGS << (Q_INT32)maxPlayers();
- //streamGS << (Q_INT32)minPlayers();
+ //streamGS << (TQ_INT32)maxPlayers();
+ //streamGS << (TQ_INT32)minPlayers();
// send to the newly connected client *only*
- Q_INT16 v=KGameMessage::version();
- Q_INT32 c=cookie();
+ TQ_INT16 v=KGameMessage::version();
+ TQ_INT32 c=cookie();
streamGS << v << c;
sendSystemMessage(streamGS, KGameMessage::IdSetupGame, clientID);
}
-bool KGame::sendGroupMessage(const TQByteArray &msg, int msgid, Q_UINT32 sender, const TQString& group)
+bool KGame::sendGroupMessage(const TQByteArray &msg, int msgid, TQ_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,10 +1411,10 @@ bool KGame::sendGroupMessage(const TQByteArray &msg, int msgid, Q_UINT32 sender,
return true;
}
-bool KGame::sendGroupMessage(const TQDataStream &msg, int msgid, Q_UINT32 sender, const TQString& group)
+bool KGame::sendGroupMessage(const TQDataStream &msg, int msgid, TQ_UINT32 sender, const TQString& group)
{ return sendGroupMessage(((TQBuffer*)msg.device())->buffer(), msgid, sender, group); }
-bool KGame::sendGroupMessage(const TQString& msg, int msgid, Q_UINT32 sender, const TQString& group)
+bool KGame::sendGroupMessage(const TQString& msg, int msgid, TQ_UINT32 sender, const TQString& group)
{
TQByteArray buffer;
TQDataStream stream(buffer, IO_WriteOnly);
@@ -1425,7 +1425,7 @@ bool KGame::sendGroupMessage(const TQString& msg, int msgid, Q_UINT32 sender, co
bool KGame::addProperty(KGamePropertyBase* data)
{ return dataHandler()->addProperty(data); }
-bool KGame::sendPlayerProperty(int msgid, TQDataStream& s, Q_UINT32 playerId)
+bool KGame::sendPlayerProperty(int msgid, TQDataStream& s, TQ_UINT32 playerId)
{ return sendSystemMessage(s, msgid, playerId); }
void KGame::sendProperty(int msgid, TQDataStream& stream, bool* sent)
@@ -1443,7 +1443,7 @@ void KGame::emitSignal(KGamePropertyBase *me)
}
KGamePropertyBase* KGame::findProperty(int id) const
-{ return d->mProperties->find(id); }
+{ return d->mProperties->tqfind(id); }
KGame::GamePolicy KGame::policy() const
{