void RestrictionWriter::Write(RelationElement const & relationElement) { if (!IsOpened()) return; CHECK_EQUAL(relationElement.GetType(), "restriction", ()); // Note. For the time being only line-point-line road restriction is supported. if (relationElement.nodes.size() != 1 || relationElement.ways.size() != 2) return; // Unsupported restriction. For example line-line-line. // Extracting osm ids of lines and points of the restriction. auto const findTag = [&relationElement](vector<pair<uint64_t, string>> const & members, string const & tag) { auto const it = find_if(members.cbegin(), members.cend(), [&tag](pair<uint64_t, string> const & p) { return p.second == tag; }); return it; }; auto const fromIt = findTag(relationElement.ways, "from"); if (fromIt == relationElement.ways.cend()) return; auto const toIt = findTag(relationElement.ways, "to"); if (toIt == relationElement.ways.cend()) return; if (findTag(relationElement.nodes, "via") == relationElement.nodes.cend()) return; // Extracting type of restriction. auto const tagIt = relationElement.tags.find("restriction"); if (tagIt == relationElement.tags.end()) return; Restriction::Type type = Restriction::Type::No; if (!TagToType(tagIt->second, type)) return; // Adding restriction. m_stream << ToString(type) << "," << fromIt->first << ", " << toIt->first << '\n'; }
TConnectionPtr CAudioSystemEditor_wwise::CreateConnectionFromXMLNode(XmlNodeRef pNode, EACEControlType eATLControlType) { if (pNode) { const string sTag = pNode->getTag(); TImplControlType type = TagToType(sTag); if (type != AUDIO_IMPL_INVALID_TYPE) { string sName = pNode->getAttr("wwise_name"); string sLocalised = pNode->getAttr("wwise_localised"); bool bLocalised = (sLocalised.compareNoCase("true") == 0); // If control not found, create a placeholder. // We want to keep that connection even if it's not in the middleware. // The user could be using the engine without the wwise project IAudioSystemControl* pControl = GetControlByName(sName, bLocalised); if (pControl == nullptr) { pControl = CreateControl(SControlDef(sName, type)); if (pControl) { pControl->SetPlaceholder(true); pControl->SetLocalised(bLocalised); } } // If it's a switch we actually connect to one of the states within the switch if (type == eWCT_WWISE_SWITCH_GROUP || type == eWCT_WWISE_GAME_STATE_GROUP) { if (pNode->getChildCount() == 1) { pNode = pNode->getChild(0); if (pNode) { string sChildName = pNode->getAttr("wwise_name"); IAudioSystemControl* pChildControl = GetControlByName(sChildName, false, pControl); if (pChildControl == nullptr) { pChildControl = CreateControl(SControlDef(sChildName, type == eWCT_WWISE_SWITCH_GROUP ? eWCT_WWISE_SWITCH : eWCT_WWISE_GAME_STATE, false, pControl)); } pControl = pChildControl; } } else { CryWarning(VALIDATOR_MODULE_EDITOR, VALIDATOR_ERROR, "Audio Controls Editor (Wwise): Error reading connection to Wwise control %s", sName); } } if (pControl) { pControl->SetConnected(true); ++m_connectionsByID[pControl->GetId()]; if (type == eWCT_WWISE_RTPC) { switch (eATLControlType) { case EACEControlType::eACET_RTPC: { TRtpcConnectionPtr pConnection = std::make_shared<CRtpcConnection>(pControl->GetId()); float mult = 1.0f; float shift = 0.0f; if (pNode->haveAttr("atl_mult")) { const string sProperty = pNode->getAttr("atl_mult"); mult = (float)std::atof(sProperty.c_str()); } if (pNode->haveAttr("atl_shift")) { const string sProperty = pNode->getAttr("atl_shift"); shift = (float)std::atof(sProperty.c_str()); } pConnection->fMult = mult; pConnection->fShift = shift; return pConnection; } case EACEControlType::eACET_SWITCH_STATE: { TStateConnectionPtr pConnection = std::make_shared<CStateToRtpcConnection>(pControl->GetId()); float value = 0.0f; if (pNode->haveAttr("atl_mult")) { const string sProperty = pNode->getAttr("wwise_value"); value = (float)std::atof(sProperty.c_str()); } pConnection->fValue = value; return pConnection; } } } else { return std::make_shared<IAudioConnection>(pControl->GetId()); } } } } return nullptr; }