containercontrols.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002                           cargodialog.cpp  -  description
00003                              -------------------
00004     begin                : Tue Oct 24 2000
00005     copyright            : (C) 2000 by Martin Bickel
00006     email                : bickel@asc-hq.org
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 #include "containercontrols.h"
00019 #include "gamemap.h"
00020 #include "mapdisplayinterface.h"
00021 #include "itemrepository.h"
00022 
00023 
00024 const GameMap* ContainerConstControls::getMap() const
00025 {
00026    return container->getMap();
00027 }
00028 
00029 
00030 const Player& ContainerConstControls::getPlayer() const
00031 {
00032    return getMap()->player[ getMap()->actplayer ];
00033 }
00034 
00035 
00036 bool ContainerConstControls::unitProductionAvailable() const
00037 {
00038    if ( container->getOwner() == container->getMap()->actplayer )
00039       if ( container->vehiclesLoaded() < container->baseType->maxLoadableUnits )
00040          if ( container->baseType->hasFunction( ContainerBaseType::InternalVehicleProduction ))
00041            return true;
00042 
00043    return false;
00044 }
00045 
00046 int  ContainerConstControls::unitProductionPrerequisites( const VehicleType* type, bool internally ) const
00047 {
00048    int l = 0;
00049    Resources cost = container->getProductionCost( type );
00050    for ( int r = 0; r < resourceTypeNum; r++ )
00051       if ( container->getAvailableResource( cost.resource(r), r ) < cost.resource(r) )
00052          l |= 1 << r;
00053    
00054    if ( internally ) {
00055       if ( !type->techDependency.available( getPlayer().research ) && getMap()->getgameparameter( cgp_produceOnlyResearchedStuffInternally ) ) 
00056          l |= 1 << 10;
00057    
00058       if ( !container->vehicleUnloadable( type ) && !container->baseType->hasFunction( ContainerBaseType::ProduceNonLeavableUnits ))
00059          l |= 1 << 11;
00060    } else {
00061       if ( !type->techDependency.available( getPlayer().research ) && getMap()->getgameparameter( cgp_produceOnlyResearchedStuffExternally ) ) 
00062          l |= 1 << 10;
00063    }
00064       
00065    return l;
00066 }
00067 
00068 

Generated on Mon May 21 01:26:30 2012 for Advanced Strategic Command by  doxygen 1.5.1