コード例 #1
0
ファイル: ResourcePool.cpp プロジェクト: Blue42hand/freeorion
float ResourcePool::GroupAvailable(int object_id) const {
    DebugLogger() << "ResourcePool::GroupAvailable(" << object_id << ")";
    // available is stockpile + production in this group

    if (m_stockpile_object_id == INVALID_OBJECT_ID)
        return GroupOutput(object_id);

    // need to find if stockpile object is in the requested object's group
    for (std::map<std::set<int>, float>::const_iterator it = m_connected_object_groups_resource_output.begin();
         it != m_connected_object_groups_resource_output.end(); ++it)
    {
        const std::set<int>& group = it->first;
        if (group.find(object_id) != group.end()) {
            // found group for requested object.  is stockpile also in this group?
            if (group.find(m_stockpile_object_id) != group.end())
                return it->second + m_stockpile;    // yes; add stockpile to production to return available
            else
                return it->second;                  // no; just return production as available
        }
    }

    // default return case:
    DebugLogger() << "ResourcePool::GroupAvailable passed unknown object id: " << object_id;
    return 0.0;
}
コード例 #2
0
float ResourcePool::GroupAvailable(int object_id) const {
    DebugLogger() << "ResourcePool::GroupAvailable(" << object_id << ")";
    // available is stockpile + production in this group

    if (m_stockpile_object_id == INVALID_OBJECT_ID)
        return GroupOutput(object_id);

    // need to find if stockpile object is in the requested object's group
    for (const auto& entry : m_connected_object_groups_resource_output) {
        const auto& group = entry.first;
        if (group.find(object_id) != group.end()) {
            // found group for requested object.  is stockpile also in this group?
            if (group.find(m_stockpile_object_id) != group.end())
                return entry.second + m_stockpile;    // yes; add stockpile to production to return available
            else
                return entry.second;                  // no; just return production as available
        }
    }

    // default return case:
    DebugLogger() << "ResourcePool::GroupAvailable passed unknown object id: " << object_id;
    return 0.0;
}
コード例 #3
0
ファイル: ResourcePool.cpp プロジェクト: Vezzra/freeorion
float ResourcePool::GroupAvailable(int object_id) const {
    DebugLogger() << "ResourcePool::GroupAvailable(" << object_id << ")";
    // available is production in this group
    return GroupOutput(object_id);
}