Update of /cvsroot/wpdev/wolfpack
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv452
Modified Files:
ChangeLog items.cpp serverconfig.cpp trade.cpp
Log Message:
Rewrote vendor buy handling.
Index: trade.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/trade.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** trade.cpp 8 Oct 2004 01:13:16 -0000 1.14
--- trade.cpp 30 Oct 2004 16:03:20 -0000 1.15
***************
*** 127,131 ****
Q_UINT16 amount = packet->iAmount( i );
! Q_UINT8 layer = packet->iLayer( i );
// First check: is the item on the vendor in the specified layer
--- 127,131 ----
Q_UINT16 amount = packet->iAmount( i );
! Q_UINT8 layer = pItem->getOutmostItem()->layer();
// First check: is the item on the vendor in the specified layer
***************
*** 138,141 ****
--- 138,143 ----
return;
}
+
+ amount = QMIN(pItem->restock(), amount);
}
else if ( layer == 0x1B )
***************
*** 147,150 ****
--- 149,155 ----
return;
}
+
+ // Not enough of that item is left
+ amount = QMIN(pItem->amount(), amount);
}
else
***************
*** 155,174 ****
}
! // Check amount
! if ( pItem->restock() > pItem->amount() )
! pItem->setRestock( pItem->amount() );
!
! // Nothing of that item left
! if ( pItem->restock() == 0 )
! continue;
!
! totalValue += amount * pItem->buyprice();
!
! if ( amount )
items.insert( make_pair( pItem->serial(), amount ) );
}
! if ( !items.size() )
! {
socket->send( &clearBuy );
pVendor->talk( 500190, 0, 0, false, 0xFFFF, pChar->socket() ); // Thou hast bought nothing!
--- 160,170 ----
}
! if (amount) {
! totalValue += amount * pItem->buyprice();
items.insert( make_pair( pItem->serial(), amount ) );
+ }
}
! if ( !items.size() ) {
socket->send( &clearBuy );
pVendor->talk( 500190, 0, 0, false, 0xFFFF, pChar->socket() ); // Thou hast bought nothing!
***************
*** 206,212 ****
{
P_ITEM pItem = FindItemBySerial( iter->first );
! Q_UINT16 amount = QMIN( iter->second, pItem->restock() );
!
! pItem->setRestock( pItem->restock() - amount ); // Reduce the items in stock
P_ITEM pSold;
--- 202,206 ----
{
P_ITEM pItem = FindItemBySerial( iter->first );
! Q_UINT16 amount = iter->second; // we already checked if there is enough in stock
P_ITEM pSold;
***************
*** 215,218 ****
--- 209,213 ----
pSold = pItem->dupe();
pSold->removeTag( "restock" ); // Remove the restock tag;
+ pSold->removeTag( "buy_time" );
pSold->setAmount( iter->second );
pPack->addItem( pSold );
***************
*** 226,229 ****
--- 221,225 ----
pSold = pItem->dupe();
pSold->removeTag( "restock" ); // Remove the restock tag;
+ pSold->removeTag( "buy_time" );
pSold->setAmount( 1 );
pPack->addItem( pSold );
***************
*** 233,237 ****
}
! //socket->sysMessage( tr( "You put the %1 into your pack" ).arg( pItem->getName() ) );
}
--- 229,238 ----
}
! P_ITEM pCont = (P_ITEM)pItem->container();
! if (pCont->layer() == cBaseChar::BuyRestockContainer) {
! pItem->setRestock( pItem->restock() - amount ); // Reduce the items in stock
! } else {
! pItem->reduceAmount( amount );
! }
}
***************
*** 343,347 ****
unsigned int sellprice = pItem->getSellPrice(pVendor);
! if (!sellprice) {
socket->sysMessage( tr( "Invalid item sold." ) );
socket->send( &clearBuy );
--- 344,348 ----
unsigned int sellprice = pItem->getSellPrice(pVendor);
! if (!sellprice || !pItem->buyprice()) {
socket->sysMessage( tr( "Invalid item sold." ) );
socket->send( &clearBuy );
***************
*** 361,365 ****
{
P_ITEM pItem = FindItemBySerial( iter->first );
! Q_UINT16 amount = iter->second;
if ( pItem->isPileable() )
--- 362,402 ----
{
P_ITEM pItem = FindItemBySerial( iter->first );
! Q_UINT16 amount = QMIN(pItem->amount(), iter->second);
!
! // If we can find something to stack with that is already in the vendors
! // no restock container, increase the amount of that item instead.
! // otherwise use the oldsytle handling.
! /*if (pItem->isPileable()) {
! bool processed = false;
! cItem::ContainerContent packContent = pBought->content();
! cItem::ContainerContent::const_iterator cit;
! for (cit = packContent.begin(); cit != packContent.end(); ++cit) {
! P_ITEM pOtherItem = *cit;
! if (pItem->canStack(pOtherItem) && pOtherItem->amount() < 65000) {
! unsigned int realAmount = QMIN(65000 - pOtherItem->amount(), amount);
!
! pOtherItem->setAmount(pOtherItem->amount() + realAmount);
! pOtherItem->setTag("buy_time", Server::instance()->time());
!
! if ( pItem->amount() <= realAmount ) {
! pItem->remove();
! } else {
! pItem->setAmount( pItem->amount() - realAmount );
! pItem->update();
! }
!
! if (realAmount == amount) {
! processed = true;
! break;
! } else {
! amount -= realAmount;
! }
! }
! }
!
! if (processed) {
! continue; // Next item
! }
! }*/
if ( pItem->isPileable() )
***************
*** 367,378 ****
P_ITEM pSold = pItem->dupe();
pSold->removeTag( "restock" );
! pSold->setAmount( iter->second );
pBought->addItem( pSold );
pSold->update();
! if ( pItem->amount() <= iter->second )
pItem->remove();
! else
! pItem->setAmount( pItem->amount() - iter->second );
! pItem->update();
}
else
--- 404,417 ----
P_ITEM pSold = pItem->dupe();
pSold->removeTag( "restock" );
! pSold->setAmount( amount );
! pSold->setTag("buy_time", Server::instance()->time());
pBought->addItem( pSold );
pSold->update();
! if ( pItem->amount() <= amount ) {
pItem->remove();
! } else {
! pItem->setAmount( pItem->amount() - amount );
! pItem->update();
! }
}
else
Index: ChangeLog
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/ChangeLog,v
retrieving revision 1.127
retrieving revision 1.128
diff -C2 -d -r1.127 -r1.128
*** ChangeLog 30 Oct 2004 11:04:42 -0000 1.127
--- ChangeLog 30 Oct 2004 16:03:20 -0000 1.128
***************
*** 16,19 ****
--- 16,21 ----
open a container.
- Fixed shop restock.
+ - Fixed bug #0000364. (Vendors not selling items they bought)
+ - Rewrote the vendor buy handler code.
Wolfpack 12.9.12 Beta (18. October 2004)
Index: items.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/items.cpp,v
retrieving revision 1.456
retrieving revision 1.457
diff -C2 -d -r1.456 -r1.457
*** items.cpp 27 Oct 2004 15:04:42 -0000 1.456
--- items.cpp 30 Oct 2004 16:03:20 -0000 1.457
***************
*** 2069,2073 ****
// Do some basic checks and see if the item is a
// container (they never stack).
! if ( id() != pItem->id() || color() != pItem->color() || type() == 1 || type() != pItem->type() || bindmenu() != pItem->bindmenu() || scriptList() != pItem->scriptList() || baseid() != pItem->baseid() )
{
return false;
--- 2069,2073 ----
// Do some basic checks and see if the item is a
// container (they never stack).
! if ( name() != pItem->name() || id() != pItem->id() || color() != pItem->color() || type() == 1 || scriptList() != pItem->scriptList() || baseid() != pItem->baseid() )
{
return false;
***************
*** 2075,2082 ****
// Check Tags (rather expensive)
! if ( tags_ != pItem->tags_ )
{
return false;
! }
return true;
--- 2075,2082 ----
// Check Tags (rather expensive)
! /*if ( tags_ != pItem->tags_ )
{
return false;
! }*/
return true;
Index: serverconfig.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/serverconfig.cpp,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** serverconfig.cpp 30 Oct 2004 11:04:42 -0000 1.17
--- serverconfig.cpp 30 Oct 2004 16:03:20 -0000 1.18
***************
*** 160,164 ****
tamedDisappear_ = getNumber( "General", "Tamed Disappear", 0, true );
houseInTown_ = getNumber( "General", "House In Town", 0, true );
! shopRestock_ = getNumber( "General", "Shop Restock", 30, true );
quittime_ = getNumber( "General", "Char Time Out", 300, true );
cacheMulFiles_ = getBool( "General", "Cache Mul Files", true, true );
--- 160,164 ----
tamedDisappear_ = getNumber( "General", "Tamed Disappear", 0, true );
houseInTown_ = getNumber( "General", "House In Town", 0, true );
! shopRestock_ = getNumber( "General", "Shop Restock", 60, true );
quittime_ = getNumber( "General", "Char Time Out", 300, true );
cacheMulFiles_ = getBool( "General", "Cache Mul Files", true, true );
|