Master::PlotInfo Master::plotInfo(const size_t key, const Data::Type type) { bool qFlow(false); bool qGauge(false); MyDB::Stmt s(mDB); s << "SELECT " << fields.gaugeKey() << "," << fields.displayName() << "," << fields.location(); switch (type) { case Data::FLOW: case Data::INFLOW: qFlow = true; s << "," << fields.lowFlow() << "," << fields.highFlow() << "," << fields.optimalLowFlow() << "," << fields.optimalHighFlow(); break; case Data::GAUGE: qGauge = true; s << "," << fields.lowGauge() << "," << fields.highGauge(); break; case Data::TEMPERATURE: case Data::LASTTYPE: break; } s << "," << fields.latitudePutin() << "," << fields.longitudePutin() << " FROM " << fields.table() << " WHERE " << fields.key() << "=" << key << ";"; int rc(s.step()); if (rc == SQLITE_ROW) { const int gaugeKey(s.getInt()); const std::string displayName(s.getString()); const std::string location(s.getString()); const double low (qFlow || qGauge ? s.getDouble() : 0); const double high(qFlow || qGauge ? s.getDouble() : 0); const double lowOptimal (qFlow ? s.getDouble() : 0); const double highOptimal(qFlow ? s.getDouble() : 0); const double lat(s.getDouble()); const double lon(s.getDouble()); return PlotInfo(gaugeKey, displayName, location, low, high, lowOptimal, highOptimal, lat, lon); } s.errorCheck(rc, std::string(__FILE__) + " line " + Convert::toStr(__LINE__)); return PlotInfo(); }
DotMapItem::DotMapPlotData::DotMapPlotData(const CvPlot* pPlot, PlayerTypes playerType, int lookAheadDepth) : workedImprovement(-1), neighbourCityCount(0), workedByNeighbour(false), isPinned(false), isSelected(true), improvementMakesBonusValid(false) { TeamTypes teamType = PlayerIDToTeamID(playerType); coords = XYCoords(pPlot->getX(), pPlot->getY()); possibleImprovements = getYields(PlotInfo(pPlot, playerType).getInfo(), playerType, lookAheadDepth); bonusType = pPlot->getBonusType(teamType); featureType = pPlot->getFeatureType(); ImprovementTypes currentPlotImprovement = pPlot->getImprovementType(); for (size_t i = 0, count = possibleImprovements.size(); i < count; ++i) { // todo - check featuretype too if (possibleImprovements[i].second == currentPlotImprovement) { workedImprovement = i; if (currentPlotImprovement != NO_IMPROVEMENT && bonusType != NO_BONUS && gGlobals.getImprovementInfo(currentPlotImprovement).isImprovementBonusMakesValid(bonusType)) { improvementMakesBonusValid = true; } break; } } }