1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
/***************************************************************************
cargodialog.cpp - description
-------------------
begin : Tue Oct 24 2000
copyright : (C) 2000 by Martin Bickel
email : bickel@asc-hq.org
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "containercontrols.h"
#include "gamemap.h"
#include "mapdisplayinterface.h"
#include "itemrepository.h"
const GameMap* ContainerConstControls::getMap() const
{
return container->getMap();
}
const Player& ContainerConstControls::getPlayer() const
{
return getMap()->player[ getMap()->actplayer ];
}
bool ContainerConstControls::unitProductionAvailable() const
{
if ( container->getOwner() == container->getMap()->actplayer )
if ( container->vehiclesLoaded() < container->baseType->maxLoadableUnits )
if ( container->baseType->hasFunction( ContainerBaseType::InternalVehicleProduction ))
return true;
return false;
}
int ContainerConstControls::unitProductionPrerequisites( const VehicleType* type, bool internally ) const
{
int l = 0;
Resources cost = container->getProductionCost( type );
for ( int r = 0; r < resourceTypeNum; r++ )
if ( container->getAvailableResource( cost.resource(r), r ) < cost.resource(r) )
l |= 1 << r;
if ( internally ) {
if ( !type->techDependency.available( getPlayer().research ) && getMap()->getgameparameter( cgp_produceOnlyResearchedStuffInternally ) )
l |= 1 << 10;
if ( !container->vehicleUnloadable( type ) && !container->baseType->hasFunction( ContainerBaseType::ProduceNonLeavableUnits ))
l |= 1 << 11;
} else {
if ( !type->techDependency.available( getPlayer().research ) && getMap()->getgameparameter( cgp_produceOnlyResearchedStuffExternally ) )
l |= 1 << 10;
}
return l;
}
|