Re: Auctions and the protocol

Albert 'TSDgeos' Astals Cid <[email protected]>
Newsgroups gmane.comp.kde.devel.atlantik
Message-ID <[email protected]>
I think i have it working, please have a look at the patch

Here is the full patch for atlantik and monopd

All I've done is:

MONOPD

Add pTmp->setBoolProperty("can_auction", m_auctionsEnabled); to 
Game::start(Player *pInput)

Add p->setBoolProperty("can_auction", m_auctionsEnabled); to 
Game::addPlayer(Player *p, bool isMaster)

And remove the =0 that was causing that i could not compile (if it is 
necessary for other compilers, architectures don't erase it)


ATLANTIK

change m_auctionEstate->setEnabled(player->canBuy()); for 
m_auctionEstate->setEnabled(player->canAuction()); in 
Atlantik::playerChanged(Player *player)

Add Player::setCanAuction(bool canAuction) and bool Player::CanAuction()

Add the can_auction option in atlantik_network.cpp

Remove another layout warning in libatlantikui/estatedetails.cpp


And lots off changes i haven't made and maybe kwrite is responsible for them 
(erased spaces at the end of lines and such things)

_______________________________________________
atlantik-devel mailing list
[email protected]
http://mail.kde.org/mailman/listinfo/atlantik-devel
monopd.diff (text/x-diff, 5.3 KB)
? monopd.diff
Index: game.cc
===================================================================
RCS file: /cvsroot/monopd/monopd/game.cc,v
retrieving revision 1.280
diff -u -r1.280 game.cc
--- game.cc	2 Jun 2003 16:00:19 -0000	1.280
+++ game.cc	6 Jun 2003 20:21:30 -0000
@@ -115,7 +115,7 @@
 {
 	va_list arg;
 	char buf[2048];
-	
+
 	va_start(arg, data);
 	vsnprintf(buf, sizeof(buf)-1, data, arg);
 	va_end(arg);
@@ -295,19 +295,19 @@
 		es->setIcon(strtok(NULL, "\n\0"));
 	else if (!strcmp(buf, "price"))
 		es->setPrice(atoi(strtok(NULL, "\n\0")));
-	else if (!strcmp(buf, "mortgageprice")) 
+	else if (!strcmp(buf, "mortgageprice"))
 	{
 		es->setMortgagePrice(atoi(strtok(NULL, "\n\0")));
 		mortgageprice_set = true;
 	}
-	else if (!strcmp(buf, "unmortgageprice")) 
+	else if (!strcmp(buf, "unmortgageprice"))
 	{
 		es->setUnmortgagePrice(atoi(strtok(NULL, "\n\0")));
 		unmortgageprice_set = true;
 	}
 	else if (!strcmp(buf, "houseprice"))
 		es->setHousePrice(atoi(strtok(NULL, "\n\0")));
-	else if (!strcmp(buf, "sellhouseprice")) 
+	else if (!strcmp(buf, "sellhouseprice"))
 	{
 		es->setSellHousePrice(atoi(strtok(NULL, "\n\0")));
 		sellhouseprice_set = true;
@@ -467,6 +467,7 @@
 		pTmp->reset(false);
 		pTmp->setEstate(m_goEstate);
 		pTmp->addMoney(m_startMoney);
+		pTmp->setBoolProperty("can_auction", m_auctionsEnabled);
 	}
 
 	for(std::vector<Player *>::iterator it = m_players.begin(); it != m_players.end() && (pTmp = *it) ; ++it)
@@ -530,7 +531,7 @@
 	}
 
 	// Find out if there are still clients busy with movement.
-	if (clientsMoving()) 
+	if (clientsMoving())
 		return;
 
 	// Land player!
@@ -624,7 +625,7 @@
 	return 0;
 }
 
-bool Game::hasDebt() 
+bool Game::hasDebt()
 {
 	for(std::vector<Debt *>::iterator it = m_debts.begin(); it != m_debts.end(); ++it)
 		if (*it)
@@ -751,7 +752,7 @@
 	delDebt(debt);
 }
 
-void Game::newAuction(Player *pInput) 
+void Game::newAuction(Player *pInput)
 {
 	if (!m_auctionsEnabled || !totalAssets())
 	{
@@ -807,7 +808,7 @@
 		pInput->ioError("You don't have %d.", bid);
 		return 1;
 	}
-	
+
 	int highestBid = m_auction->getIntProperty("highbid");
 	if (bid <= highestBid)
 	{
@@ -854,7 +855,7 @@
 	Trade *tTmp = 0;
 	for(std::vector<Trade *>::iterator it = m_trades.begin(); it != m_trades.end() && (tTmp = *it) ; ++it)
 		if (tradeId == tTmp->id()) return tTmp;
-	
+
 	return 0;
 }
 
@@ -980,7 +981,7 @@
 		m_pTurn->setBoolProperty("can_roll", true);
 		setDisplay(estate, false, false, "%s may roll again.", m_pTurn->name().c_str());
 	}
-	else 
+	else
 		updateTurn();
 }
 
@@ -988,7 +989,7 @@
 {
 	va_list arg;
 	char buf[2048];
-	
+
 	va_start(arg, data);
 	vsnprintf(buf, sizeof(buf)-1, data, arg);
 	va_end(arg);
@@ -1004,7 +1005,7 @@
 	}
 }
 
-void Game::sendMsgEstateUpdate(Estate *e) 
+void Game::sendMsgEstateUpdate(Estate *e)
 {
 	Estate *eTmp = 0;
 	Player *pTmp = 0;
@@ -1242,6 +1243,7 @@
 	p->setBoolProperty("can_roll", false);
 	p->setBoolProperty("canrollagain", false);
 	p->setBoolProperty("can_buyestate", false);
+	p->setBoolProperty("can_auction", m_auctionsEnabled);
 
 	if (isMaster)
 		m_master = p;
@@ -1274,7 +1276,7 @@
 	for(std::vector<Player *>::iterator it = m_players.begin(); it != m_players.end() && (pTmp = *it) ; ++it)
 		if(id == pTmp->id())
 			return pTmp;
-	
+
 	return 0;
 }
 
@@ -1348,7 +1350,7 @@
 	{
 		if (!pFirst && !player->getBoolProperty("bankrupt"))
 			pFirst = player;
-			
+
 		if (player == pOldTurn)
 			useNext = true;
 		else if (useNext && !player->getBoolProperty("bankrupt") && !player->getBoolProperty("spectator"))
@@ -1408,7 +1410,7 @@
 
 	// Store and write final data.
 	pTurn->addMoney(money);
-	
+
 	// Hm, we wait for all tokens to have landed, this is exactly what we
 	// were trying to avoid with async updates! So some of this stuff can be
 	// sent earlier.
@@ -1506,7 +1508,7 @@
 		{
 			payAmount = ( tax ? tax : (int)(taxPercentage * pTurn->assets() / 100 ) );
 			Estate * const ePayTarget = es->payTarget();
-				
+
 			if (!pTurn->payMoney(payAmount))
 			{
 				// TODO: If we go into debt here, we'll never enter rent
@@ -1540,7 +1542,7 @@
 		if ((pOwner = es->owner()))
 		{
 			// Owned.
-			
+
 			if (pOwner == pTurn)
 				setDisplay(es, false, false, "%s already owns it.", pTurn->name().c_str());
 			else if (es->getBoolProperty("mortgaged"))
@@ -1848,7 +1850,7 @@
 {
 	unsigned int moving = 0;
 	Player *pTmp = 0;
-	for(std::vector<Player *>::iterator it = m_players.begin(); it != m_players.end() && (pTmp = *it) ; ++it) 
+	for(std::vector<Player *>::iterator it = m_players.begin(); it != m_players.end() && (pTmp = *it) ; ++it)
 		if (pTmp->tokenLocation())
 			moving++;
 	return moving;
Index: gameobject.cc
===================================================================
RCS file: /cvsroot/monopd/monopd/gameobject.cc,v
retrieving revision 1.9
diff -u -r1.9 gameobject.cc
--- gameobject.cc	8 Mar 2003 17:36:05 -0000	1.9
+++ gameobject.cc	6 Jun 2003 20:21:31 -0000
@@ -47,7 +47,7 @@
 	return m_game;
 }
 
-void GameObject::setProperty(const std::string &key, const std::string &value, GameObject *scope = 0)
+void GameObject::setProperty(const std::string &key, const std::string &value, GameObject *scope)
 {
 	GameStringProperty *stringProperty = 0;
 	for(std::vector<GameStringProperty *>::iterator it = m_stringProperties.begin() ; it != m_stringProperties.end() && (stringProperty = *it) ; ++it)
atlantik.diff (text/x-diff, 5.5 KB)
? atlantik.diff
? client/diff
Index: client/atlantik.cpp
===================================================================
RCS file: /home/kde/kdegames/atlantik/client/atlantik.cpp,v
retrieving revision 1.141
diff -u -r1.141 atlantik.cpp
--- client/atlantik.cpp	25 Feb 2003 04:20:38 -0000	1.141
+++ client/atlantik.cpp	6 Jun 2003 20:17:18 -0000
@@ -136,8 +136,8 @@
 	// Check command-line args to see if we need to connect or show Monopigator window
 	KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
 
-	QCString host = args->getOption("host");	
-	QCString port = args->getOption("port");	
+	QCString host = args->getOption("host");
+	QCString port = args->getOption("port");
 	if (!host.isNull() && !port.isNull())
 		m_atlantikNetwork->serverConnect(host, port.toInt());
 	else
@@ -373,7 +373,7 @@
 	// Check command-line args to see if we need to auto-join
 	KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
 
-	QCString game = args->getOption("game");	
+	QCString game = args->getOption("game");
 	if (!game.isNull())
 		m_atlantikNetwork->joinGame(game.toInt());
 	else
@@ -383,7 +383,7 @@
 void Atlantik::slotNetworkError(int errnum)
 {
 	QString errMsg(i18n("Error connecting: "));
-	
+
 	switch (m_atlantikNetwork->status())
 	{
 		case IO_ConnectError:
@@ -413,7 +413,7 @@
 	if (m_configDialog == 0)
 		m_configDialog = new ConfigDialog(this);
 	m_configDialog->show();
-	
+
 	connect(m_configDialog, SIGNAL(okClicked()), this, SLOT(slotUpdateConfig()));
 }
 
@@ -543,7 +543,7 @@
 
 		m_roll->setEnabled(player->canRoll());
 		m_buyEstate->setEnabled(player->canBuy());
-		m_auctionEstate->setEnabled(player->canBuy());
+		m_auctionEstate->setEnabled(player->canAuction());
 
 		// TODO: Should be more finetuned, but monopd doesn't send can_endturn can_usejailcard can_payjail can_jailroll yet
 		m_endTurn->setEnabled(player->hasTurn() && !(player->canRoll() || player->canBuy() || player->inJail()));
Index: libatlantic/player.cpp
===================================================================
RCS file: /home/kde/kdegames/atlantik/libatlantic/player.cpp,v
retrieving revision 1.16
diff -u -r1.16 player.cpp
--- libatlantic/player.cpp	19 Jan 2003 23:57:26 -0000	1.16
+++ libatlantic/player.cpp	6 Jun 2003 20:17:18 -0000
@@ -28,7 +28,7 @@
 	m_location = m_destination = 0;
 	m_money = 0;
 	m_changed = m_isSelf = false;
-	m_master = m_hasTurn = m_canRoll = m_canBuy = m_inJail = false;
+	m_master = m_hasTurn = m_canRoll = m_canBuy = m_canAuction = m_inJail = false;
 }
 
 void Player::setGame(int gameId)
@@ -90,6 +90,15 @@
 	if (m_canBuy != canBuy)
 	{
 		m_canBuy = canBuy;
+		m_changed = true;
+	}
+}
+
+void Player::setCanAuction(bool canAuction)
+{
+	if (m_canAuction != canAuction)
+	{
+		m_canAuction = canAuction;
 		m_changed = true;
 	}
 }
Index: libatlantic/player.h
===================================================================
RCS file: /home/kde/kdegames/atlantik/libatlantic/player.h,v
retrieving revision 1.13
diff -u -r1.13 player.h
--- libatlantic/player.h	19 Jan 2003 23:57:26 -0000	1.13
+++ libatlantic/player.h	6 Jun 2003 20:17:18 -0000
@@ -46,6 +46,8 @@
 	bool canRoll() const { return m_canRoll; }
 	void setCanBuy(bool canBuy);
 	bool canBuy() const { return m_canBuy; }
+	void setCanAuction(bool canAuction);
+	bool canAuction() const { return m_canAuction; }
 	void setInJail(const bool inJail);
 	bool inJail() const { return m_inJail; }
 	void setName(const QString _n);
@@ -64,7 +66,7 @@
 private:
 	int m_id, m_gameId;
 	bool m_changed, m_isSelf;
-	bool m_master, m_hasTurn, m_canRoll, m_canBuy, m_inJail;
+	bool m_master, m_hasTurn, m_canRoll, m_canBuy, m_canAuction, m_inJail;
 	unsigned int m_money;
 	QString m_name, m_host, m_image;
 	Estate *m_location, *m_destination;
Index: libatlantikclient/atlantik_network.cpp
===================================================================
RCS file: /home/kde/kdegames/atlantik/libatlantikclient/atlantik_network.cpp,v
retrieving revision 1.84
diff -u -r1.84 atlantik_network.cpp
--- libatlantikclient/atlantik_network.cpp	8 Feb 2003 15:36:03 -0000	1.84
+++ libatlantikclient/atlantik_network.cpp	6 Jun 2003 20:17:19 -0000
@@ -465,6 +465,11 @@
 					if (player && !a.isNull())
 						player->setCanBuy(a.value().toInt());
 
+					// Update whether player can auction
+					a = e.attributeNode(QString("can_auction"));
+					if (player && !a.isNull())
+						player->setCanAuction(a.value().toInt());
+
 					// Update whether player is jailed
 					a = e.attributeNode(QString("jailed"));
 					if (player && !a.isNull())
@@ -515,7 +520,7 @@
 
 					EstateGroup *estateGroup = 0;
 					bool b_newEstateGroup = false;
-					
+
 					if (!(estateGroup = m_atlanticCore->findEstateGroup(groupId)))
 					{
 						// Create EstateGroup object
@@ -545,7 +550,7 @@
 				if (!a.isNull())
 				{
 					estateId = a.value().toInt();
-					
+
 					Estate *estate = 0;
 					bool b_newEstate = false;
 
Index: libatlantikui/estatedetails.cpp
===================================================================
RCS file: /home/kde/kdegames/atlantik/libatlantikui/estatedetails.cpp,v
retrieving revision 1.22
diff -u -r1.22 estatedetails.cpp
--- libatlantikui/estatedetails.cpp	12 Feb 2003 03:03:42 -0000	1.22
+++ libatlantikui/estatedetails.cpp	6 Jun 2003 20:17:20 -0000
@@ -62,7 +62,8 @@
 	if (!text.isEmpty())
 		appendText(text);
 
-	m_buttonBox = new QHBoxLayout(this, 0, KDialog::spacingHint());
+	m_buttonBox = new QHBoxLayout(m_mainLayout, KDialog::spacingHint());
+	m_buttonBox->setMargin(0);
 	m_mainLayout->addItem(m_buttonBox);
 
 	m_buttonBox->addItem(new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum));
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.