/* $Id: bonushomingvirus.cpp,v 1.3 2005/10/05 14:46:44 chfreund Exp $ */ #include "bonushomingvirus.hpp" #include "avatar.hpp" /**********************************************************/ #define HOMING_VIRUS_MAX_IMPACT 10 #define HOMING_VIRUS_HEALT 300000 /**********************************************************/ BonusHomingVirus::BonusHomingVirus( World* wp ) : m_numDefenses( wp->getRandom().getUint32Between (1, HOMING_VIRUS_MAX_IMPACT) ) { m_worldPointer = wp; // set health for the bonus m_health = HOMING_VIRUS_HEALT; // for mass and collission rectangle take the // default values from base class Bonus // THIS CALL MUST BE PART OF EACH CONSTRUCTOR // OF BONI, DERIVED FROM ITS BASE CLASS Bonus registerAtManager(); } /**********************************************************/ BonusHomingVirus::~BonusHomingVirus() { // THIS CALL MUST BE PART OF EACH DENSTRUCTOR // OF BONI, DERIVED FROM ITS BASE CLASS Bonus unregisterAtManager(); } /**********************************************************/ void BonusHomingVirus::add( const Bonus *const bonus ) { const BonusHomingVirus *const virus = dynamic_cast(bonus); DBG(1) ASSERT( virus != NULL, "BonusHomingVirus::add: attempt to add a bonus " " of type $s to a shield bonus", bonus->getIDString() ); m_numDefenses += virus->getNumDefenses(); } /**********************************************************/ Uint32 BonusHomingVirus::getSerializeBufferSize() const { return Bonus::getSerializeBufferSize() + Serialize::sizeOf( m_numDefenses ) // adds additional size for debugging (see serialize.hpp), // but only, if the tags are used PLUS_TAG_SIZE( 1 ); } /**********************************************************/ void BonusHomingVirus::serialize( Uint8*& bufferPointer ) const { // expands to a check of the buffer movement START_OBJECT_SERIALIZED_SIZE_CHECK( bufferPointer ); // serialize base class Bonus::serialize( bufferPointer ); // deserialize member variables Serialize::serialize( m_numDefenses, bufferPointer ); // expands to tag serialization SERIALIZE_OBJECT_TAG( bufferPointer ); // expands to a check of the buffer movement END_OBJECT_SERIALIZED_SIZE_CHECK( bufferPointer, BonusHomingVirus ); } /**********************************************************/ void BonusHomingVirus::deserialize( Uint8*& bufferPointer ) { // deserialize base class Bonus::deserialize( bufferPointer ); // deserialize member variables Serialize::deserialize( bufferPointer, m_numDefenses ); // expands to tag deserialization DESERIALIZE_OBJECT_TAG( bufferPointer ); } /**********************************************************/