[atlantik-cvs] CVS: kdegames/atlantik/libatlantikclient atlantik_network.cpp,1.65,1.66 atlantik_network.h,1.34,1.35 monopdprotocol.cpp,1.1,1.2

[email protected]
Newsgroups gmane.comp.kde.devel.atlantik
Message-ID <[email protected]>
Update of /home/kde/kdegames/atlantik/libatlantikclient
In directory office:/tmp/cvs-serv6542/libatlantikclient

Modified Files:
	atlantik_network.cpp atlantik_network.h monopdprotocol.cpp 
Log Message:
qmap->qptrlist changes, improved estatedetails widget

Index: atlantik_network.cpp
===================================================================
RCS file: /home/kde/kdegames/atlantik/libatlantikclient/atlantik_network.cpp,v
retrieving revision 1.65
retrieving revision 1.66
diff -u -d -r1.65 -r1.66
--- atlantik_network.cpp	2002/11/04 19:33:02	1.65
+++ atlantik_network.cpp	2002/11/27 21:08:56	1.66
@@ -82,28 +82,28 @@
 void AtlantikNetwork::tokenConfirmation(Estate *estate)
 {
 	QString msg(".t");
-	msg.append(QString::number(estate ? estate->estateId() : -1));
+	msg.append(QString::number(estate ? estate->id() : -1));
 	writeData(msg);
 }
 
 void AtlantikNetwork::estateToggleMortgage(Estate *estate)
 {
 	QString msg(".em");
-	msg.append(QString::number(estate ? estate->estateId() : -1));
+	msg.append(QString::number(estate ? estate->id() : -1));
 	writeData(msg);
 }
 
 void AtlantikNetwork::estateHouseBuy(Estate *estate)
 {
 	QString msg(".hb");
-	msg.append(QString::number(estate ? estate->estateId() : -1));
+	msg.append(QString::number(estate ? estate->id() : -1));
 	writeData(msg);
 }
 
 void AtlantikNetwork::estateHouseSell(Estate *estate)
 {
 	QString msg(".hs");
-	msg.append(QString::number(estate ? estate->estateId() : -1));
+	msg.append(QString::number(estate ? estate->id() : -1));
 	writeData(msg);
 }
 
@@ -134,7 +134,7 @@
 void AtlantikNetwork::newTrade(Player *player)
 {
 	QString msg(".Tn");
-	msg.append(QString::number(player ? m_playerRevMap[player] : -1));
+	msg.append(QString::number(player ? player->id() : -1));
 	writeData(msg);
 }
 
@@ -143,9 +143,9 @@
 	QString msg(".Te");
 	msg.append(QString::number(trade ? trade->tradeId() : -1));
 	msg.append(":");
-	msg.append(QString::number(estate ? estate->estateId() : -1));
+	msg.append(QString::number(estate ? estate->id() : -1));
 	msg.append(":");
-	msg.append(QString::number(player ? m_playerRevMap[player] : -1));
+	msg.append(QString::number(player ? player->id() : -1));
 	writeData(msg);
 }
 
@@ -154,9 +154,9 @@
 	QString msg(".Tm");
 	msg.append(QString::number(trade ? trade->tradeId() : -1));
 	msg.append(":");
-	msg.append(QString::number(pFrom ? m_playerRevMap[pFrom] : -1));
+	msg.append(QString::number(pFrom ? pFrom->id() : -1));
 	msg.append(":");
-	msg.append(QString::number(pTo ? m_playerRevMap[pTo] : -1));
+	msg.append(QString::number(pTo ? pTo->id() : -1));
 	msg.append(":");
 	msg.append(QString::number(money));
 	writeData(msg);
@@ -277,11 +277,9 @@
 				{
 					estateId = a.value().toInt();
 					Estate *estate;
-					if ((estate = m_estates[a.value().toInt()]))
+					if ((estate = m_atlanticCore->findEstate(a.value().toInt())))
 					{
-						emit displayEstate(estate);
-						// TODO: merge into displayEstate, or statusbar
-						emit msgInfo(e.attributeNode(QString("text")).value());
+						emit displayDetails(e.attributeNode(QString("text")).value(), estate);
 
 						bool hasButtons = false;
 						for( QDomNode nButtons = n.firstChild() ; !nButtons.isNull() ; nButtons = nButtons.nextSibling() )
@@ -411,12 +409,10 @@
 
 					Player *player;
 					bool b_newPlayer = false;
-					if (!(player = m_playerMap[playerId]))
+					if (!(player = m_atlanticCore->findPlayer(playerId)))
 					{
 						// Create player object
-						player = m_atlanticCore->newPlayer();
-						m_playerMap[playerId] = player;
-						m_playerRevMap[player] = playerId;
+						player = m_atlanticCore->newPlayer(playerId);
 
 						if (playerId == m_playerId)
 							player->setIsSelf(true);
@@ -462,15 +458,15 @@
 					{
 						m_playerLocationMap[player] = a.value().toInt();
 
-						Estate *estate = m_estates[a.value().toInt()];
 						bool directMove = false;
 
+						Estate *estate = m_atlanticCore->findEstate(a.value().toInt());
+						if (estate)
+							player->setLocation(estate);
+
 						a = e.attributeNode(QString("directmove"));
 						if (!a.isNull())
 							directMove = a.value().toInt();
-
-						if (estate)
-							player->setLocation(estate);
 					}
 
 					// Emit signal so GUI implementations can create view(s)
@@ -490,15 +486,13 @@
 				{
 					int groupId = a.value().toInt();
 
-					EstateGroup *estateGroup;
+					EstateGroup *estateGroup = 0;
 					bool b_newEstateGroup = false;
 					
-					if (!(estateGroup = m_estateGroups[groupId]))
+					if (!(estateGroup = m_atlanticCore->findEstateGroup(groupId)))
 					{
 						// Create EstateGroup object
 						estateGroup = m_atlanticCore->newEstateGroup(a.value().toInt());
-						m_estateGroups[groupId] = estateGroup;
-
 						b_newEstateGroup = true;
 					}
 
@@ -525,26 +519,24 @@
 				{
 					estateId = a.value().toInt();
 					
-					Estate *estate;
+					Estate *estate = 0;
 					bool b_newEstate = false;
-					if (!(estate = m_estates[a.value().toInt()]))
+					if (!(estate = m_atlanticCore->findEstate(a.value().toInt())))
 					{
 						// Create estate object
 						estate = m_atlanticCore->newEstate(estateId);
-						m_estates[estateId] = estate;
+						b_newEstate = true;
 
 						QObject::connect(estate, SIGNAL(estateToggleMortgage(Estate *)), this, SLOT(estateToggleMortgage(Estate *)));
 						QObject::connect(estate, SIGNAL(estateHouseBuy(Estate *)), this, SLOT(estateHouseBuy(Estate *)));
 						QObject::connect(estate, SIGNAL(estateHouseSell(Estate *)), this, SLOT(estateHouseSell(Estate *)));
 						QObject::connect(estate, SIGNAL(newTrade(Player *)), this, SLOT(newTrade(Player *)));
 
-						b_newEstate = true;
-
 						// Players without estate should get one
 						Player *player = 0;
 						QPtrList<Player> playerList = m_atlanticCore->players();
 						for (QPtrListIterator<Player> it(playerList); (player = *it) ; ++it)
-							if (m_playerLocationMap[player] == estate->estateId())
+							if (m_playerLocationMap[player] == estate->id())
 								player->setLocation(estate);
 					}
 
@@ -561,7 +553,7 @@
 						estate->setBgColor(a.value());
 
 					a = e.attributeNode(QString("owner"));
-					Player *player = m_playerMap[a.value().toInt()];
+					Player *player = m_atlanticCore->findPlayer(a.value().toInt());
 					if (estate && !a.isNull())
 						estate->setOwner(player);
 
@@ -576,7 +568,7 @@
 					a = e.attributeNode(QString("group"));
 					if (!a.isNull())
 					{
-						EstateGroup *estateGroup = m_estateGroups[a.value().toInt()];
+						EstateGroup *estateGroup = m_atlanticCore->findEstateGroup(a.value().toInt());
 						if (estate)
 							estate->setEstateGroup(estateGroup);
 					}
@@ -637,7 +629,7 @@
 					if (type=="new")
 					{
 						// TODO: trade->setActor
-						// Player *player = m_playerMap[e.attributeNode(QString("actor")).value().toInt()];
+						// Player *player = m_atlanticCore->findPlayer(e.attributeNode(QString("actor")).value().toInt());
 						// if (trade && player)
 						// 	trade->setActor(player);
 
@@ -647,7 +639,7 @@
 							QDomElement e_player = n_player.toElement();
 							if (!e_player.isNull() && e_player.tagName() == "tradeplayer")
 							{
-								Player *player = m_playerMap[e_player.attributeNode(QString("playerid")).value().toInt()];
+								Player *player = m_atlanticCore->findPlayer(e_player.attributeNode(QString("playerid")).value().toInt());
 								if (trade && player)
 									trade->addPlayer(player);
 							}
@@ -664,7 +656,7 @@
 					}
 					else if (type=="rejected")
 					{
-						Player *player = m_playerMap[e.attributeNode(QString("actor")).value().toInt()];
+						Player *player = m_atlanticCore->findPlayer(e.attributeNode(QString("actor")).value().toInt());
 						if (trade)
 							trade->reject(player);
 						if (player && player->isSelf())
@@ -689,7 +681,7 @@
 									a = e_child.attributeNode(QString("playerid"));
 									if (!a.isNull())
 									{
-										Player *player = m_playerMap[a.value().toInt()];
+										Player *player = m_atlanticCore->findPlayer(a.value().toInt());
 
 										a = e_child.attributeNode(QString("accept"));
 										if (trade && player && !a.isNull())
@@ -701,11 +693,11 @@
 									a = e_child.attributeNode(QString("estateid"));
 									if (!a.isNull())
 									{
-										Estate *estate = m_estates[a.value().toInt()];
+										Estate *estate = m_atlanticCore->findEstate(a.value().toInt());
 										a = e_child.attributeNode(QString("targetplayer"));
 										if (!a.isNull())
 										{
-											Player *player = m_playerMap[a.value().toInt()];
+											Player *player = m_atlanticCore->findPlayer(a.value().toInt());
 											// Allow NULL player, it will remove the component
 											if (trade && estate)
 												trade->updateEstate(estate, player);
@@ -718,11 +710,11 @@
 
 									a = e_child.attributeNode(QString("playerfrom"));
 									if (!a.isNull())
-										pFrom = m_playerMap[a.value().toInt()];
+										pFrom = m_atlanticCore->findPlayer(a.value().toInt());
 
 									a = e_child.attributeNode(QString("playerto"));
 									if (!a.isNull())
-										pTo = m_playerMap[a.value().toInt()];
+										pTo = m_atlanticCore->findPlayer(a.value().toInt());
 
 									a = e_child.attributeNode(QString("money"));
 									kdDebug() << "tradeupdatemoney" << (pFrom ? "1" : "0") << (pTo ? "1" : "0") << (a.isNull() ? "0" : "1") << endl;
@@ -756,7 +748,7 @@
 					if (!(auction = m_auctions[auctionId]))
 					{
 						// Create auction object
-						auction = m_atlanticCore->newAuction(auctionId, m_estates[e.attributeNode(QString("estateid")).value().toInt()]);
+						auction = m_atlanticCore->newAuction(auctionId, m_atlanticCore->findEstate(e.attributeNode(QString("estateid")).value().toInt()));
 						m_auctions[auctionId] = auction;
 
 						QObject::connect(auction, SIGNAL(bid(Auction *, int)), this, SLOT(auctionBid(Auction *, int)));
@@ -767,7 +759,7 @@
 					a = e.attributeNode(QString("highbidder"));
 					if (!a.isNull())
 					{
-						Player *player = m_playerMap[e.attributeNode(QString("highbidder")).value().toInt()];
+						Player *player = m_atlanticCore->findPlayer(e.attributeNode(QString("highbidder")).value().toInt());
 						a = e.attributeNode(QString("highbid"));
 						if (auction && !a.isNull())
 							auction->newBid(player, a.value().toInt());

Index: atlantik_network.h
===================================================================
RCS file: /home/kde/kdegames/atlantik/libatlantikclient/atlantik_network.h,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- atlantik_network.h	2002/10/23 19:18:19	1.34
+++ atlantik_network.h	2002/11/27 21:08:56	1.35
@@ -115,8 +115,7 @@
 	void msgError(QString);
 	void msgChat(QString, QString);
 
-	void displayText(QString title, QString description);
-	void displayEstate(Estate *);
+	void displayDetails(QString text, Estate *estate = 0);
 	void displayDefault();
 	void addCommandButton(QString command, QString caption, bool enabled);
 	void addCloseButton();
@@ -169,11 +168,7 @@
 
 	int m_playerId;
 
-	QMap<int, Player *> m_playerMap;
-	QMap<Player *, int> m_playerRevMap;
 	QMap<Player *, int> m_playerLocationMap;
-	QMap<int, Estate *> m_estates;
-	QMap<int, EstateGroup *> m_estateGroups;
 	QMap<int, Trade *> m_trades;
 	QMap<int, Auction *> m_auctions;
 };

Index: monopdprotocol.cpp
===================================================================
RCS file: /home/kde/kdegames/atlantik/libatlantikclient/monopdprotocol.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- monopdprotocol.cpp	2002/06/29 13:35:12	1.1
+++ monopdprotocol.cpp	2002/11/27 21:08:56	1.2
@@ -47,7 +47,7 @@
 void MonopdProtocol::confirmTokenLocation(Estate *estate)
 {
 	QString data(".t");
-	data.append(QString::number(estate ? estate->estateId() : -1));
+	data.append(QString::number(estate ? estate->id() : -1));
 	sendData(data);
 }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.