Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

selfdestruct.cpp

Go to the documentation of this file.
00001 /*
00002      This file is part of Advanced Strategic Command; http://www.asc-hq.de
00003      Copyright (C) 1994-1999  Martin Bickel  and  Marc Schellenberger
00004  
00005      This program is free software; you can redistribute it and/or modify
00006      it under the terms of the GNU General Public License as published by
00007      the Free Software Foundation; either version 2 of the License, or
00008      (at your option) any later version.
00009  
00010      This program is distributed in the hope that it will be useful,
00011      but WITHOUT ANY WARRANTY; without even the implied warranty of
00012      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013      GNU General Public License for more details.
00014  
00015      You should have received a copy of the GNU General Public License
00016      along with this program; see the file COPYING. If not, write to the 
00017      Free Software Foundation, Inc., 59 Temple Place, Suite 330, 
00018      Boston, MA  02111-1307  USA
00019 */
00020 
00021 
00022 #include "selfdestruct.h"
00023 #include "../gamemap.h"
00024 #include "../vehicle.h"
00025 #include "../spfst.h"
00026 #include "../viewcalculation.h"
00027 #include "../replay.h"
00028 #include "../soundList.h"
00029 #include "../reactionfire.h"
00030 
00031 bool SelfDestruct::available( const ContainerBase* subject )
00032 {
00033    if ( subject )
00034      if ( subject->baseType->hasFunction( ContainerBaseType::ManualSelfDestruct ) ) {
00035         Player& player = subject->getMap()->getPlayer(subject);
00036         if ( player.diplomacy.isAllied( subject->getMap()->actplayer)  ) 
00037            return true;
00038      }
00039 
00040    return false;
00041 };
00042 
00043 
00044 bool SelfDestruct::destruct( ContainerBase* subject )
00045 {
00046    if ( !available(subject ))
00047       return false;
00048 
00049    GameMap* map = subject->getMap();
00050 
00051    logtoreplayinfo( rpl_selfdestruct, subject->getIdentification() );
00052    
00053    Vehicle* v = dynamic_cast<Vehicle*>(subject);
00054    if ( v )
00055       SoundList::getInstance().playSound( SoundList::unitExplodes , 0, false, v->typ->killSoundLabel );
00056    else 
00057       SoundList::getInstance().playSound( SoundList::buildingCollapses );
00058      
00059    delete subject;
00060       
00061    evaluateviewcalculation( map );
00062   
00063    return true;
00064 }
00065 

Generated on Tue Jun 24 01:27:51 2008 for Advanced Strategic Command by  doxygen 1.4.2