Update of /cvsroot/wpdev/wolfpack
In directory sc8-pr-cvs1:/tmp/cvs-serv22317
Modified Files:
basechar.cpp house.cpp items.cpp npc.cpp player.cpp
wolfpack.vcproj wpdefmanager.cpp wpdefmanager.h
Log Message:
Fixed a bug player and npc equipment not being sent and fixed a bug with saving the baseid property. Also improved handling of several tags in the definitions. It's not <item inherit anylonger but <item id
Index: basechar.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/basechar.cpp,v
retrieving revision 1.48
retrieving revision 1.49
diff -C2 -d -r1.48 -r1.49
*** basechar.cpp 24 Nov 2003 02:36:10 -0000 1.48
--- basechar.cpp 24 Nov 2003 03:14:51 -0000 1.49
***************
*** 1156,1213 ****
else if( TagName == "equipped" )
{
! std::vector< const cElement* > equipment;
!
! unsigned int i;
! for( i = 0; i < Tag->childCount(); ++i )
{
! const cElement *childNode = Tag->getChild( i );
! if( childNode->name() == "item" )
! equipment.push_back( childNode );
! else if( childNode->name() == "getlist" && childNode->hasAttribute( "id" ) )
{
! QStringList list = DefManager->getList( childNode->getAttribute( "id" ) );
!
! for( QStringList::iterator it = list.begin(); it != list.end(); it++ )
{
! const cElement *listNode = DefManager->getDefinition( WPDT_ITEM, *it );
!
! if( listNode )
! equipment.push_back( listNode );
}
! }
! }
!
! std::vector< const cElement* >::iterator iter = equipment.begin();
!
! while( iter != equipment.end() )
! {
! P_ITEM nItem = new cItem;
!
! if( nItem == NULL )
! continue;
!
! nItem->Init( true );
! nItem->applyDefinition( *iter );
! UINT8 mLayer = nItem->layer();
! nItem->setLayer( 0 );
! // Instead of deleting try to get a valid layer instead
! if( !mLayer )
! {
! tile_st tInfo = TileCache::instance()->getTile( nItem->id() );
! if( tInfo.layer > 0 )
! mLayer = tInfo.layer;
}
-
- // Recheck
- if( !mLayer )
- nItem->remove();
else
! this->addItem( static_cast<cBaseChar::enLayer>(mLayer), nItem ); // not sure about this one.
!
! ++iter;
}
}
--- 1156,1212 ----
else if( TagName == "equipped" )
{
! for( unsigned int i = 0; i < Tag->childCount(); ++i )
{
! const cElement *element = Tag->getChild( i );
! if( element->name() == "item" )
{
! P_ITEM pItem = 0;
!
! const QString &id = element->getAttribute( "id" );
!
! if( id != QString::null )
{
! pItem = cItem::createFromScript( id );
}
! else
! {
! const QString &list = element->getAttribute( "list" );
! if( list != QString::null )
! {
! pItem = cItem::createFromList( list );
! }
! }
! if( pItem )
! {
! pItem->applyDefinition( element );
! unsigned char mLayer = pItem->layer();
! pItem->setLayer( 0 );
!
! // Instead of deleting try to get a valid layer instead
! if( !mLayer )
! {
! tile_st tInfo = TileCache::instance()->getTile( pItem->id() );
! if( tInfo.layer > 0 )
! mLayer = tInfo.layer;
! }
!
! if( !mLayer )
! pItem->remove();
! else
! addItem( static_cast<cBaseChar::enLayer>(mLayer), pItem );
! }
! else
! {
! Console::instance()->log( LOG_ERROR, QString( "Invalid equipped element missing id and list attribute in npc definition '%1'." ).arg( element->getTopmostParent()->getAttribute( "id", "unknown" ) ) );
! }
}
else
! {
! Console::instance()->log( LOG_ERROR, QString( "Invalid equipped element '%1' in npc definition '%2'." ).arg( element->name() ).arg( element->getTopmostParent()->getAttribute( "id", "unknown" ) ) );
! }
}
}
Index: house.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/house.cpp,v
retrieving revision 1.116
retrieving revision 1.117
diff -C2 -d -r1.116 -r1.117
*** house.cpp 11 Sep 2003 16:19:50 -0000 1.116
--- house.cpp 24 Nov 2003 03:14:52 -0000 1.117
***************
*** 66,70 ****
nItem->Init( true );
-
nItem->applyDefinition( Tag );
--- 66,69 ----
Index: items.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/items.cpp,v
retrieving revision 1.359
retrieving revision 1.360
diff -C2 -d -r1.359 -r1.360
*** items.cpp 24 Nov 2003 02:36:10 -0000 1.359
--- items.cpp 24 Nov 2003 03:14:52 -0000 1.360
***************
*** 480,483 ****
--- 480,484 ----
addField("buyprice", buyprice_ );
addField("restock", restock_ );
+ addStrField("baseid", base ? base->id() : QString("") );
addCondition( "serial", serial() );
***************
*** 1336,1378 ****
}
! void cItem::processContainerNode( const cElement *Tag )
{
//item containers can be scripted like this:
/*
<contains>
! <item><inherit list="myList" /></item>
! <item><inherit id="myItem1" /><amount><random ... /></amount><color><colorlist><random...></colorlist></color></item>
...
</contains>
*/
! std::vector< const cElement* > content;
! unsigned int i;
!
! for( i = 0; i < Tag->childCount(); ++i )
{
! const cElement *childNode = Tag->getChild( i );
! if( childNode->name() == "item" )
! {
! content.push_back( childNode );
! }
! else if( childNode->name() == "getlist" && childNode->hasAttribute( "id" ) )
{
! QStringList list = DefManager->getList( childNode->getAttribute( "id" ) );
!
! for( QStringList::iterator it = list.begin(); it != list.end(); it++ )
{
- const cElement *lItem = DefManager->getDefinition( WPDT_ITEM, *it );
- content.push_back( lItem );
}
! }
! }
!
! for( i = 0; i < content.size(); i++ )
! {
! P_ITEM nItem = new cItem;
! nItem->Init( true );
! nItem->applyDefinition( content[ i ] );
! addItem( nItem );
}
}
--- 1337,1373 ----
}
! void cItem::processContainerNode( const cElement *tag )
{
//item containers can be scripted like this:
/*
<contains>
! <item list="myList" />
! <item id="myItem1"><amount><random ... /></amount><color><colorlist><random...></colorlist></color></item>
...
</contains>
*/
! for( unsigned int i = 0; i < tag->childCount(); ++i )
{
! const cElement *element = tag->getChild( i );
! if( element->name() == "item" )
{
! P_ITEM pItem = 0;
!
! if( element->hasAttribute( "id" ) )
{
}
! else if( element->hasAttribute( "list" ) )
! {
! }
! else
! {
! Console::instance()->log( LOG_ERROR, QString( "Content element lacking id and list attribute in item definition '%1'." ).arg( element->getTopmostParent()->getAttribute( "id", "unknown" ) ) );
! }
! }
! else
! {
! Console::instance()->log( LOG_ERROR, QString( "Unknown content element '%1' in item definition '%1'." ).arg( element->name(), element->getTopmostParent()->getAttribute( "id", "unknown" ) ) );
! }
}
}
***************
*** 1876,1879 ****
--- 1871,1875 ----
buyprice_ = atoi( result[offset++] );
restock_ = atoi( result[offset++] );
+ base = ItemBases::instance()->getItemBase( result[offset++] );
// Their own weight should already be set.
Index: npc.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/npc.cpp,v
retrieving revision 1.50
retrieving revision 1.51
diff -C2 -d -r1.50 -r1.51
*** npc.cpp 10 Oct 2003 21:13:46 -0000 1.50
--- npc.cpp 24 Nov 2003 03:14:52 -0000 1.51
***************
*** 291,294 ****
--- 291,299 ----
sendTooltip( mSock );
mSock->send( &drawChar );
+
+ for( ItemContainer::const_iterator it = content_.begin(); it != content_.end(); ++it )
+ {
+ it.data()->sendTooltip( mSock );
+ }
}
}
Index: player.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/player.cpp,v
retrieving revision 1.47
retrieving revision 1.48
diff -C2 -d -r1.47 -r1.48
*** player.cpp 24 Nov 2003 02:36:10 -0000 1.47
--- player.cpp 24 Nov 2003 03:14:52 -0000 1.48
***************
*** 232,240 ****
if( mSock == socket_ )
{
! sendTooltip( mSock );
continue;
}
-
P_PLAYER pChar = mSock->player();
--- 232,239 ----
if( mSock == socket_ )
{
! sendTooltip( mSock );
continue;
}
P_PLAYER pChar = mSock->player();
***************
*** 260,263 ****
--- 259,268 ----
sendTooltip( mSock );
mSock->send( &drawChar );
+
+ // Send equipment of other players as well
+ for( ItemContainer::const_iterator it = content_.begin(); it != content_.end(); ++it )
+ {
+ it.data()->sendTooltip( mSock );
+ }
}
}
Index: wolfpack.vcproj
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/wolfpack.vcproj,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** wolfpack.vcproj 24 Nov 2003 02:36:10 -0000 1.3
--- wolfpack.vcproj 24 Nov 2003 03:14:53 -0000 1.4
***************
*** 243,250 ****
RelativePath=".\dragdrop.h"/>
<File
- RelativePath=".\encryption.cpp"/>
- <File
- RelativePath=".\encryption.h"/>
- <File
RelativePath=".\exceptions.h"/>
<File
--- 243,246 ----
***************
*** 557,560 ****
--- 553,560 ----
Name="Encryption"
Filter="">
+ <File
+ RelativePath=".\encryption.cpp"/>
+ <File
+ RelativePath=".\encryption.h"/>
<File
RelativePath=".\twofish\twofish2.c"/>
Index: wpdefmanager.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/wpdefmanager.cpp,v
retrieving revision 1.71
retrieving revision 1.72
diff -C2 -d -r1.71 -r1.72
*** wpdefmanager.cpp 24 Nov 2003 02:36:10 -0000 1.71
--- wpdefmanager.cpp 24 Nov 2003 03:14:53 -0000 1.72
***************
*** 619,625 ****
}
! cElement *cElement::parent() const
{
return parent_;
}
--- 619,635 ----
}
! const cElement *cElement::parent() const
{
return parent_;
+ }
+
+ const cElement *cElement::getTopmostParent() const
+ {
+ if( parent_ )
+ {
+ return parent_->getTopmostParent();
+ }
+
+ return this;
}
Index: wpdefmanager.h
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/wpdefmanager.h,v
retrieving revision 1.33
retrieving revision 1.34
diff -C2 -d -r1.33 -r1.34
*** wpdefmanager.h 24 Nov 2003 02:36:10 -0000 1.33
--- wpdefmanager.h 24 Nov 2003 03:14:53 -0000 1.34
***************
*** 121,127 ****
void setParent( cElement *parent );
! cElement *parent() const;
QString getValue() const;
};
--- 121,129 ----
void setParent( cElement *parent );
! const cElement *parent() const;
QString getValue() const;
+
+ const cElement *getTopmostParent() const;
};
|