Update of /cvsroot/wpdev/wolfpack
In directory sc8-pr-cvs1:/tmp/cvs-serv9890/src
Modified Files:
customtags.cpp customtags.h items.h wolfpack.cpp
Log Message:
Reduced the CodeSize of both, cItem and cUObject
Index: customtags.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/customtags.cpp,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -d -r1.24 -r1.25
*** customtags.cpp 26 Aug 2003 15:36:44 -0000 1.24
--- customtags.cpp 27 Aug 2003 13:33:17 -0000 1.25
***************
*** 657,661 ****
cCustomTags::cCustomTags( const cCustomTags& d )
{
! tags_ = d.tags_;
changed = true;
}
--- 657,665 ----
cCustomTags::cCustomTags( const cCustomTags& d )
{
! if( d.tags_ )
! tags_ = d.tags_;
! else
! tags_ = new QMap< QString, cVariant >( *d.tags_ );
!
changed = true;
}
***************
*** 664,668 ****
{
changed = true;
! tags_ = tags.tags_;
return *this;
}
--- 668,676 ----
{
changed = true;
! if( tags.tags_ )
! tags_ = new QMap< QString, cVariant >( *tags.tags_ );
! else
! tags_ = 0;
!
return *this;
}
***************
*** 680,687 ****
persistentBroker->executeQuery( QString( "DELETE FROM tags WHERE serial = '%1'" ).arg( key ) );
! QMap< QString, cVariant >::const_iterator it( tags_.begin() );
! if ( tags_.count() > 6 )
! persistentBroker->lockTable("tags");
! for( ; it != tags_.end(); ++it )
{
// Erase invalid tags.
--- 688,700 ----
persistentBroker->executeQuery( QString( "DELETE FROM tags WHERE serial = '%1'" ).arg( key ) );
! if( !tags_ )
! {
! changed = false;
! return;
! }
!
! QMap< QString, cVariant >::const_iterator it( tags_->begin() );
!
! for( ; it != tags_->end(); ++it )
{
// Erase invalid tags.
***************
*** 698,703 ****
persistentBroker->executeQuery( QString( "INSERT INTO tags SET serial = '%1', type = '%2', value = '%3', name = '%4'" ).arg( key ).arg( type ).arg( persistentBroker->quoteString( value ) ).arg( persistentBroker->quoteString( name ) ) );
}
- if ( tags_.count() > 6 )
- persistentBroker->unlockTable("tags");
changed = false;
--- 711,714 ----
***************
*** 706,710 ****
void cCustomTags::load( SERIAL key )
{
! tags_.clear();
cDBResult result = persistentBroker->query( QString( "SELECT serial,name,type,value FROM tags WHERE serial = '%1'" ).arg( key ) );
--- 717,722 ----
void cCustomTags::load( SERIAL key )
{
! if( tags_ )
! tags_->clear();
cDBResult result = persistentBroker->query( QString( "SELECT serial,name,type,value FROM tags WHERE serial = '%1'" ).arg( key ) );
***************
*** 716,725 ****
QString value = result.getString( 3 );
if( type == "String" )
! tags_.insert( name, cVariant( value ) );
else if( type == "Int" )
! tags_.insert( name, cVariant( value.toInt() ) );
else if( type == "Double" )
! tags_.insert( name, cVariant( value.toDouble() ) );
}
--- 728,740 ----
QString value = result.getString( 3 );
+ if( !tags_ )
+ tags_ = new QMap< QString, cVariant >;
+
if( type == "String" )
! tags_->insert( name, cVariant( value ) );
else if( type == "Int" )
! tags_->insert( name, cVariant( value.toInt() ) );
else if( type == "Double" )
! tags_->insert( name, cVariant( value.toDouble() ) );
}
***************
*** 730,750 ****
cVariant cCustomTags::get( const QString& key )
! {
! QMap< QString, cVariant >::iterator it = tags_.find( key );
! if( it != tags_.end() )
! return it.data();
! else
! return cVariant();
}
void cCustomTags::set( const QString& key, const cVariant& value )
{
! QMap< QString, cVariant >::iterator iter = tags_.find( key );
! if( iter != tags_.end() )
{
if( !value.isValid() )
{
! tags_.erase( iter );
changed = true;
}
--- 745,771 ----
cVariant cCustomTags::get( const QString& key )
! {
! if( tags_ )
! {
! QMap< QString, cVariant >::iterator it = tags_->find( key );
! if( it != tags_->end() )
! return it.data();
! }
!
! return cVariant();
}
void cCustomTags::set( const QString& key, const cVariant& value )
{
! if( !tags_ )
! tags_ = new QMap< QString, cVariant >;
!
! QMap< QString, cVariant >::iterator iter = tags_->find( key );
! if( iter != tags_->end() )
{
if( !value.isValid() )
{
! tags_->erase( iter );
changed = true;
}
***************
*** 757,761 ****
else
{
! tags_.insert( key, value );
changed = true;
}
--- 778,782 ----
else
{
! tags_->insert( key, value );
changed = true;
}
***************
*** 764,773 ****
void cCustomTags::remove( const QString& key )
{
! QMap< QString, cVariant >::iterator iter( tags_.find( key ) );
!
! if( iter != tags_.end() )
{
! tags_.erase( iter );
! changed = true;
}
}
--- 785,800 ----
void cCustomTags::remove( const QString& key )
{
! if( tags_ )
{
! QMap< QString, cVariant >::iterator iter( tags_->find( key ) );
!
! if( iter != tags_->end() )
! {
! tags_->erase( iter );
! changed = true;
! }
!
! if( tags_->count() == 0 )
! delete tags_;
}
}
***************
*** 775,784 ****
QStringList cCustomTags::getKeys( void )
{
! return tags_.keys();
}
QValueList< cVariant > cCustomTags::getValues( void )
{
! return tags_.values();
}
--- 802,826 ----
QStringList cCustomTags::getKeys( void )
{
! if( tags_ )
! {
! return tags_->keys();
! }
!
! return QStringList();
}
QValueList< cVariant > cCustomTags::getValues( void )
{
! if( tags_ )
! {
! return tags_->values();
! }
!
! return QValueList< cVariant >();
}
+ cCustomTags::~cCustomTags()
+ {
+ if( tags_ )
+ delete tags_;
+ }
Index: customtags.h
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/customtags.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** customtags.h 27 Aug 2003 01:39:58 -0000 1.18
--- customtags.h 27 Aug 2003 13:33:17 -0000 1.19
***************
*** 144,149 ****
{
public:
! cCustomTags(): changed( false ) {}
cCustomTags( const cCustomTags& );
void del( SERIAL key );
--- 144,150 ----
{
public:
! cCustomTags(): changed( false ), tags_( 0 ) {}
cCustomTags( const cCustomTags& );
+ virtual ~cCustomTags();
void del( SERIAL key );
***************
*** 155,159 ****
void remove( const QString& key );
! UI32 size( void ) { return this->tags_.size(); }
QStringList getKeys( void );
--- 156,160 ----
void remove( const QString& key );
! UI32 size( void ) { return tags_ ? this->tags_->size() : 0; }
QStringList getKeys( void );
***************
*** 175,179 ****
private:
! QMap< QString, cVariant > tags_;
bool changed;
};
--- 176,180 ----
private:
! QMap< QString, cVariant > *tags_;
bool changed;
};
Index: items.h
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/items.h,v
retrieving revision 1.171
retrieving revision 1.172
diff -C2 -d -r1.171 -r1.172
*** items.h 27 Aug 2003 01:39:59 -0000 1.171
--- items.h 27 Aug 2003 13:33:17 -0000 1.172
***************
*** 174,186 ****
//----------------------[ ADVANCED PROPERTIES GETTERS ]------------------
- short regen( ushort id ) const { return regen_[ id ]; } // Regeneration value
- short bonus( ushort id ) const { return statsbonus_[ id ]; } // Stats bonuses
- short damage( ushort id ) const { return damage_[ id ]; } // Damage modifiers %
- short enh( ushort id ) const { return enhancement_[ id ]; } // Misc enhancements %
- short hit( ushort id ) const { return hit_[ id ]; } // Attack and defence modifiers %
- short req( ushort id ) const { return requirements_[ id ]; } // Reagent, Mana and other requirements %
- short resist( ushort id ) const { return resist_[ id ]; } // Resisting damage %
- short reflect( ushort id ) const { return reflect_[ id ]; } // Reflecting damage %
-
short charge_count() const { return charge_count_; }
short charge_spell() const { return charge_spell_; }
--- 174,177 ----
***************
*** 267,280 ****
//----------------------[ ADVANCED PROPERTIES SETTERS ]------------------
-
- void setRegen( ushort id, short data ){ regen_.replace( id, data ); } // Regeneration value
- void setBonus( ushort id, short data ){ statsbonus_.replace( id, data ); } // Stats bonuses
- void setDamage( ushort id, short data ){ damage_.replace( id, data ); } // Damage modifiers %
- void setEnh( ushort id, short data ){ enhancement_.replace( id, data ); } // Misc enhancements %
- void setHit( ushort id, short data ){ hit_.replace( id, data ); } // Attack and defence modifiers %
- void setReq( ushort id, short data ){ requirements_.replace( id, data ); } // Reagent, Mana and other requirements %
- void setResist( ushort id, short data ){ resist_.replace( id, data ); } // Resisting damage %
- void setReflect( ushort id, short data ){ reflect_.replace( id, data ); } // Reflecting damage %
-
void setChargeCount( short data ) { charge_count_ = data; }
void setChargeSpell( short data ) { charge_spell_ = data; }
--- 258,261 ----
***************
*** 450,491 ****
ushort uses_base_; //Uses base
ushort uses_current_; //Uses current
-
- // Regenerations
- // Mana, Stamina, Hit points
- QMap< ushort, short > regen_;
-
- // Stats bonuses
- // Dexterity, Intelligence, Strength, Hit points, Mana, Stamina
- QMap< ushort, short > statsbonus_;
-
- // Damage increase %
- // Increase, Physical, Cold, Fire, Poison, Energy, Spell
- QMap< ushort, short > damage_;
-
- // Enhancements %
- // Defence chance, Gold increase, Swing speed increase
- // Enhance potions, Self repair, Faster casting, Faster cast recovery
- QMap< ushort, short > enhancement_;
-
- // Hit modifiers %
- // Chance increase, Cold, Dispel, Energy,
- // Fire, Fireball, Harm, Life leech,
- // Lighting, Lower attack, Lower defence, Magic arrow,
- // Mana leech, Physical area, Poison area, Stamina leech
- QMap< ushort, short > hit_;
-
- // Lower requirements for resources and stats consumption %
- // Low mana cost, Low reagent cost, Low requirements (global)
- QMap< ushort, short > requirements_;
-
- // Resisting %
- // Cold resist, Energy resist, Fire resist
- // Physical resist, Poison resist
- QMap< ushort, short > resist_;
-
- // Reflect %
- // Reflect physical
- QMap< ushort, short > reflect_;
-
};
--- 431,434 ----
Index: wolfpack.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/wolfpack.cpp,v
retrieving revision 1.440
retrieving revision 1.441
diff -C2 -d -r1.440 -r1.441
*** wolfpack.cpp 27 Aug 2003 01:39:59 -0000 1.440
--- wolfpack.cpp 27 Aug 2003 13:33:17 -0000 1.441
***************
*** 559,562 ****
--- 559,573 ----
#endif
*/
+ clConsole.send( "PAUSE" );
+ Sleep( 10000 );
+
+ for( unsigned int x = 0; x < 100000; ++x )
+ {
+ cItem *pItem = new cItem;
+ }
+
+ clConsole.send( "PAUSE" );
+ Sleep( 10000 );
+
QApplication app( argc, argv, false ); // we need one instance
QTranslator translator( 0 ); // must be valid thru app life.
|