Ares
Classes | Public Types | Static Public Member Functions | Static Public Attributes

BuildingTypeExt Class Reference

#include <src/Ext/BuildingType/Body.h>

List of all members.

Classes

class  cPrismForwarding
class  ExtData

Public Types

typedef BuildingTypeClass TT

Static Public Member Functions

static void UpdateSecretLabOptions (BuildingClass *pThis)
static bool IsFoundationEqual (BuildingTypeClass *pTBldA, BuildingTypeClass *pTBldB)

Static Public Attributes

static Container< BuildingTypeExtExtMap

Member Typedef Documentation

typedef BuildingTypeClass BuildingTypeExt::TT

Member Function Documentation

bool BuildingTypeExt::IsFoundationEqual ( BuildingTypeClass *  pTBldA,
BuildingTypeClass *  pTBldB 
) [static]
                                                                                            {
        if(pTBldA && pTBldB) {
                // must have same foundation id
                if(pTBldA->Foundation != pTBldB->Foundation) {
                        return false;
                }

                // non-custom foundations need no special handling
                if(pTBldA->Foundation != FOUNDATION_CUSTOM) {
                        return true;
                }

                // custom foundation
                BuildingTypeExt::ExtData *pDataA = BuildingTypeExt::ExtMap.Find(pTBldA);
                BuildingTypeExt::ExtData *pDataB = BuildingTypeExt::ExtMap.Find(pTBldB);
                if(pDataA->CustomWidth == pDataB->CustomWidth) {
                        if(pDataA->CustomHeight == pDataB->CustomHeight) {
                                // compare unsorted arrays the hard way: O(nē)
                                int length = (pDataA->CustomHeight * pDataA->CustomHeight + 1);
                                for(int i=0; i<length; ++i) {
                                        bool found = false;
                                        for(int j=0; j<length; ++j) {
                                                if((pDataA->CustomData[i].X == pDataB->CustomData[j].X) && (pDataA->CustomData[i].Y == pDataB->CustomData[j].Y)) {
                                                        found = true;
                                                        break;
                                                }
                                        }
                                        if(!found) {
                                                return false;
                                        }
                                }
                                // found everyting.
                                return true;
                        }
                }
        }
        return false;
}
void BuildingTypeExt::UpdateSecretLabOptions ( BuildingClass *  pThis) [static]
{
        BuildingTypeClass *pType = pThis->Type;
        BuildingTypeExt::ExtData* pData = BuildingTypeExt::ExtMap.Find(pType);

        DEBUGLOG("Secret Lab update for %s\n", pType->get_ID());

        if(!pData->Secret_Boons.Count || (pData->Secret_Placed && !pData->Secret_RecalcOnCapture)) {
                return;
        }

        TechnoTypeClass *Result = pType->SecretInfantry;
        if(!Result) {
                Result = pType->SecretUnit;
                if(!Result) {
                        Result = pType->SecretBuilding;
                }
        }
        if(Result) {
                pThis->SecretProduction = Result;
                return;
        }

        HouseClass *Owner = pThis->Owner;
        unsigned int OwnerBits = 1 << Owner->Type->ArrayIndex;

        DynamicVectorClass<TechnoTypeClass *> Options;
        for(int i = 0; i < pData->Secret_Boons.Count; ++i) {
                TechnoTypeClass * Option = pData->Secret_Boons.GetItem(i);
                TechnoTypeExt::ExtData* pTech = TechnoTypeExt::ExtMap.Find(Option);

                if((pTech->Secret_RequiredHouses & OwnerBits) && !(pTech->Secret_ForbiddenHouses & OwnerBits)) {
                        bool ShouldAdd = false;
                        switch(HouseExt::RequirementsMet(Owner, Option)) {
                                case HouseExt::Forbidden:
                                case HouseExt::Incomplete:
                                        ShouldAdd = true;
                                        break;
                        }
                        if(ShouldAdd) {
                                Options.AddItem(Option);
                        }
                }
        }

        if(Options.Count < 1) {
                DEBUGLOG("Secret Lab [%s] has no boons applicable to country [%s]!\n",
                        pType->ID, Owner->Type->ID);
                return;
        }

        int idx = ScenarioClass::Instance->Random.RandomRanged(0, Options.Count - 1);
        Result = Options[idx];

        DEBUGLOG("Secret Lab rolled %s for %s\n", Result->ID, pType->ID);
        pData->Secret_Placed = true;
        pThis->SecretProduction = Result;
}

Member Data Documentation


The documentation for this class was generated from the following files:
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines