SAMHeaderGroupWithID::SAMHeaderGroupWithID(const std::string & fromString) : SAMHeaderGroup(fromString) { assert (HasTag("ID")); if (not HasTag("ID")) { assert("ERROR! SAM Header read/program group must has ID tag." == 0); } _id = Tag("ID"); }
bool Tags::IsEmpty() { // At least one of these should be filled in, otherwise // it's assumed that the tags have not been set... if (HasTag(TAG_TITLE) || HasTag(TAG_ARTIST) || HasTag(TAG_ALBUM)) { return false; } return true; }
// используется при нахождении лучшего дерева клаузы. // выдает число операторов однородностей (MUA), у которых все члены имеют хотя бы одну// общую SF long CRusSemStructure::GetSemFetAgreeMNACount(long Tag) { long Result = 0; for (size_t i=0; i <m_Nodes.size(); i++) if (HasTag (i, Tag)) if (m_Nodes[i].m_NodeType == MNA) if (m_Nodes[i].m_MNAType == SimpleMNA) { long Nodes[MaxMNANodesCount]; long NodesCount = 0; for (long l=0; l < m_Nodes[i].m_OutRels.size(); l++) { long RelNo = m_Nodes[i].m_OutRels[l]; if (!m_Relations[RelNo].m_bRelUse) continue; if (!m_Relations[RelNo].m_Valency.m_RelationStr.empty() ) continue; Nodes[NodesCount++] = m_Relations[RelNo].m_TargetNodeNo; }; bool NeighboursAreGleicheSemFet = true; for (long k=1; k< NodesCount; k++) NeighboursAreGleicheSemFet = NeighboursAreGleicheSemFet && GleicheSemFet(m_Nodes[Nodes[k]].m_NodeSemFets, m_Nodes[Nodes[k-1]].m_NodeSemFets, false); if (NeighboursAreGleicheSemFet) Result ++; }; return Result; };
bool UAbility::GetTagTrue(FString name) { if (HasTag(name)) { return GetTag(name).value >= 1; } return true; }
vector<Entity*> Entity::FindAllByTagInChildren(const Tag& tag) { vector<Entity*> results; if (IsEnabled() && HasTag(tag.name)) { results.push_back(this); } for(auto it = begin(children); it != end(children); ++it) { vector<Entity*> tagChildren = FindAllByTagInChildren(tag); results.insert(end(results), begin(tagChildren), end(tagChildren)); } return results; }
long CRusSemStructure::GetAnaphoricRelationsCount(long Tag) { size_t Result =0; for (size_t i = 0; i < m_DopRelations.size(); i++) if (HasTag(m_DopRelations[i].m_SourceNodeNo, Tag)) if (m_DopRelations[i].m_bRelUse) if (m_DopRelations[i].m_SyntacticRelation == "анафора") Result++; return Result; };
Entity* Entity::FindAnyByTagInChildren(const Tag& tag) { if (IsEnabled()) { if (HasTag(tag.name)) { return this; } else { for(auto it = begin(children); it != end(children); ++it) { Entity* tagChild = FindAnyByTagInChildren(tag.name); if (tagChild) { return tagChild; } } } } return nullptr; }
bool CRoomTemplate::AddTag( const char *szTag ) { if ( !TagList() ) return false; // check it's a valid tag const char *pszFoundTag = TagList()->FindTag( szTag ); if ( !pszFoundTag ) return false; // check we don't have it already if ( HasTag( pszFoundTag ) ) return false; m_Tags.AddToTail( pszFoundTag ); return true; }
void Planet::PopGrowthProductionResearchPhase() { UniverseObject::PopGrowthProductionResearchPhase(); bool just_conquered = m_just_conquered; // do not do production if planet was just conquered m_just_conquered = false; if (!just_conquered) ResourceCenterPopGrowthProductionResearchPhase(); PopCenterPopGrowthProductionResearchPhase(); // check for colonies without positive population, and change to outposts if (!SpeciesName().empty() && GetMeter(METER_POPULATION)->Current() <= 0.0f) { if (Empire* empire = GetEmpire(this->Owner())) { empire->AddSitRepEntry(CreatePlanetDepopulatedSitRep(this->ID())); if (!HasTag(TAG_STAT_SKIP_DEPOP)) { // record depopulation of planet with species while owned by this empire std::map<std::string, int>::iterator species_it = empire->SpeciesPlanetsDepoped().find(SpeciesName()); if (species_it == empire->SpeciesPlanetsDepoped().end()) empire->SpeciesPlanetsDepoped()[SpeciesName()] = 1; else species_it->second++; } } // remove species PopCenter::Reset(); } if (!just_conquered) { GetMeter(METER_SHIELD)->SetCurrent(Planet::NextTurnCurrentMeterValue(METER_SHIELD)); GetMeter(METER_DEFENSE)->SetCurrent(Planet::NextTurnCurrentMeterValue(METER_DEFENSE)); GetMeter(METER_TROOPS)->SetCurrent(Planet::NextTurnCurrentMeterValue(METER_TROOPS)); GetMeter(METER_REBEL_TROOPS)->SetCurrent(Planet::NextTurnCurrentMeterValue(METER_REBEL_TROOPS)); GetMeter(METER_SUPPLY)->SetCurrent(Planet::NextTurnCurrentMeterValue(METER_SUPPLY)); } StateChangedSignal(); }
//-------------------------------------------------------------------------------------------------------- // Return true if this cost applies to the given actor bool CFuncNavCost::IsApplicableTo( CBaseCombatCharacter *who ) const { if ( !who ) { return false; } if ( m_team > 0 ) { if ( who->GetTeamNumber() != m_team ) { return false; } } #ifdef TF_DLL // TODO: Make group comparison efficient and move to base combat character CTFBot *bot = ToTFBot( who ); if ( bot ) { if ( bot->HasTheFlag() ) { if ( HasTag( "bomb_carrier" ) ) { return true; } // check custom bomb_carrier tags for this bot for( int i=0; i<m_tags.Count(); ++i ) { const char* pszTag = m_tags[i]; if ( V_stristr( pszTag, "bomb_carrier" ) ) { if ( bot->HasTag( pszTag ) ) { return true; } } } // the bomb carrier only pays attention to bomb_carrier costs return false; } if ( bot->HasMission( CTFBot::MISSION_DESTROY_SENTRIES ) ) { if ( HasTag( "mission_sentry_buster" ) ) { return true; } } if ( bot->HasMission( CTFBot::MISSION_SNIPER ) ) { if ( HasTag( "mission_sniper" ) ) { return true; } } if ( bot->HasMission( CTFBot::MISSION_SPY ) ) { if ( HasTag( "mission_spy" ) ) { return true; } } if ( bot->HasMission( CTFBot::MISSION_REPROGRAMMED ) ) { return false; } if ( !bot->IsOnAnyMission() ) { if ( HasTag( "common" ) ) { return true; } } if ( HasTag( bot->GetPlayerClass()->GetName() ) ) { return true; } // check custom tags for this bot for( int i=0; i<m_tags.Count(); ++i ) { if ( bot->HasTag( m_tags[i] ) ) { return true; } } // this cost doesn't apply to me return false; } #endif return false; }
bool CRoomTemplate::IsEscapeRoom() const { return HasTag( "Escape" ); }
static text_segment_t* ParseSubtitles( int *pi_align, const char *psz_subtitle ) { text_segment_t* p_segment; text_segment_t* p_first_segment; style_stack_t* p_stack = NULL; tag_stack_t* p_tag_stack = NULL; //FIXME: Remove initial allocation? Might make the below code more complicated p_first_segment = p_segment = text_segment_New( "" ); bool b_has_align = false; /* */ while( *psz_subtitle ) { /* HTML extensions */ if( *psz_subtitle == '<' ) { char *psz_tagname = GetTag( &psz_subtitle, false ); if ( psz_tagname != NULL ) { if( !strcasecmp( psz_tagname, "br" ) ) { if ( !AppendCharacter( p_segment, '\n' ) ) { free( psz_tagname ); goto fail; } } else if( !strcasecmp( psz_tagname, "b" ) ) { p_segment = NewTextSegmentPushStyle( p_segment, &p_stack ); p_segment->style->i_style_flags |= STYLE_BOLD; p_segment->style->i_features |= STYLE_HAS_FLAGS; } else if( !strcasecmp( psz_tagname, "i" ) ) { p_segment = NewTextSegmentPushStyle( p_segment, &p_stack ); p_segment->style->i_style_flags |= STYLE_ITALIC; p_segment->style->i_features |= STYLE_HAS_FLAGS; } else if( !strcasecmp( psz_tagname, "u" ) ) { p_segment = NewTextSegmentPushStyle( p_segment, &p_stack ); p_segment->style->i_style_flags |= STYLE_UNDERLINE; p_segment->style->i_features |= STYLE_HAS_FLAGS; } else if( !strcasecmp( psz_tagname, "s" ) ) { p_segment = NewTextSegmentPushStyle( p_segment, &p_stack ); p_segment->style->i_style_flags |= STYLE_STRIKEOUT; p_segment->style->i_features |= STYLE_HAS_FLAGS; } else if( !strcasecmp( psz_tagname, "font" ) ) { p_segment = NewTextSegmentPushStyle( p_segment, &p_stack ); char* psz_attribute_name; char* psz_attribute_value; while( ( psz_attribute_name = ConsumeAttribute( &psz_subtitle, &psz_attribute_value ) ) ) { if ( !strcasecmp( psz_attribute_name, "face" ) ) { p_segment->style->psz_fontname = psz_attribute_value; // We don't want to free the attribute value since it has become our fontname psz_attribute_value = NULL; } else if ( !strcasecmp( psz_attribute_name, "family" ) ) { p_segment->style->psz_monofontname = psz_attribute_value; psz_attribute_value = NULL; } else if ( !strcasecmp( psz_attribute_name, "size" ) ) { int size = atoi( psz_attribute_value ); if( size ) { p_segment->style->i_font_size = size; p_segment->style->f_font_relsize = STYLE_DEFAULT_REL_FONT_SIZE * STYLE_DEFAULT_FONT_SIZE / p_segment->style->i_font_size; } } else if ( !strcasecmp( psz_attribute_name, "color" ) ) { p_segment->style->i_font_color = vlc_html_color( psz_attribute_value, NULL ); p_segment->style->i_features |= STYLE_HAS_FONT_COLOR; } else if ( !strcasecmp( psz_attribute_name, "outline-color" ) ) { p_segment->style->i_outline_color = vlc_html_color( psz_attribute_value, NULL ); p_segment->style->i_features |= STYLE_HAS_OUTLINE_COLOR; } else if ( !strcasecmp( psz_attribute_name, "shadow-color" ) ) { p_segment->style->i_shadow_color = vlc_html_color( psz_attribute_value, NULL ); p_segment->style->i_features |= STYLE_HAS_SHADOW_COLOR; } else if ( !strcasecmp( psz_attribute_name, "outline-level" ) ) { p_segment->style->i_outline_width = atoi( psz_attribute_value ); } else if ( !strcasecmp( psz_attribute_name, "shadow-level" ) ) { p_segment->style->i_shadow_width = atoi( psz_attribute_value ); } else if ( !strcasecmp( psz_attribute_name, "back-color" ) ) { p_segment->style->i_background_color = vlc_html_color( psz_attribute_value, NULL ); p_segment->style->i_features |= STYLE_HAS_BACKGROUND_COLOR; } else if ( !strcasecmp( psz_attribute_name, "alpha" ) ) { p_segment->style->i_font_alpha = atoi( psz_attribute_value ); p_segment->style->i_features |= STYLE_HAS_FONT_ALPHA; } free( psz_attribute_name ); free( psz_attribute_value ); } } else { // This is an unknown tag. We need to hide it if it's properly closed, and display it otherwise if ( !IsClosed( psz_subtitle, psz_tagname ) ) { AppendCharacter( p_segment, '<' ); AppendString( p_segment, psz_tagname ); AppendCharacter( p_segment, '>' ); } else { AppendTag( &p_tag_stack, psz_tagname ); // We don't want to free the tagname now, it will be freed when the tag // gets poped from the stack. psz_tagname = NULL; } // In any case, fall through and skip to the closing tag. } // Skip potential spaces & end tag while ( *psz_subtitle && *psz_subtitle != '>' ) psz_subtitle++; if ( *psz_subtitle == '>' ) psz_subtitle++; free( psz_tagname ); } else if( !strncmp( psz_subtitle, "</", 2 )) { char* psz_tagname = GetTag( &psz_subtitle, true ); if ( psz_tagname != NULL ) { if ( !strcasecmp( psz_tagname, "b" ) || !strcasecmp( psz_tagname, "i" ) || !strcasecmp( psz_tagname, "u" ) || !strcasecmp( psz_tagname, "s" ) || !strcasecmp( psz_tagname, "font" ) ) { // A closing tag for one of the tags we handle, meaning // we pushed a style onto the stack earlier p_segment = NewTextSegmentPopStyle( p_segment, &p_stack ); } else { // Unknown closing tag. If it is closing an unknown tag, ignore it. Otherwise, display it if ( !HasTag( &p_tag_stack, psz_tagname ) ) { AppendString( p_segment, "</" ); AppendString( p_segment, psz_tagname ); AppendCharacter( p_segment, '>' ); } } while ( *psz_subtitle == ' ' ) psz_subtitle++; if ( *psz_subtitle == '>' ) psz_subtitle++; free( psz_tagname ); } } else { /* We have an unknown tag, just append it, and move on. * The rest of the string won't be recognized as a tag, and * we will ignore unknown closing tag */ AppendCharacter( p_segment, '<' ); psz_subtitle++; } } /* SSA extensions */ else if( psz_subtitle[0] == '{' && psz_subtitle[1] == '\\' && strchr( psz_subtitle, '}' ) ) { /* Check for forced alignment */ if( !b_has_align && !strncmp( psz_subtitle, "{\\an", 4 ) && psz_subtitle[4] >= '1' && psz_subtitle[4] <= '9' && psz_subtitle[5] == '}' ) { static const int pi_vertical[3] = { SUBPICTURE_ALIGN_BOTTOM, 0, SUBPICTURE_ALIGN_TOP }; static const int pi_horizontal[3] = { SUBPICTURE_ALIGN_LEFT, 0, SUBPICTURE_ALIGN_RIGHT }; const int i_id = psz_subtitle[4] - '1'; b_has_align = true; *pi_align = pi_vertical[i_id/3] | pi_horizontal[i_id%3]; } /* TODO fr -> rotation */ /* Hide {\stupidity} */ psz_subtitle = strchr( psz_subtitle, '}' ) + 1; } /* MicroDVD extensions */ /* FIXME: * - Currently, we don't do difference between X and x, and we should: * Capital Letters applies to the whole text and not one line * - We don't support Position and Coordinates * - We don't support the DEFAULT flag (HEADER) */ else if( psz_subtitle[0] == '{' && psz_subtitle[2] == ':' && strchr( &psz_subtitle[2], '}' ) ) { const char *psz_tag_end = strchr( &psz_subtitle[2], '}' ); size_t i_len = psz_tag_end - &psz_subtitle[3]; if( psz_subtitle[1] == 'Y' || psz_subtitle[1] == 'y' ) { if( psz_subtitle[3] == 'i' ) { p_segment = NewTextSegmentPushStyle( p_segment, &p_stack ); p_segment->style->i_style_flags |= STYLE_ITALIC; p_segment->style->i_features |= STYLE_HAS_FLAGS; psz_subtitle++; } if( psz_subtitle[3] == 'b' ) { p_segment = NewTextSegmentPushStyle( p_segment, &p_stack ); p_segment->style->i_style_flags |= STYLE_BOLD; p_segment->style->i_features |= STYLE_HAS_FLAGS; psz_subtitle++; } if( psz_subtitle[3] == 'u' ) { p_segment = NewTextSegmentPushStyle( p_segment, &p_stack ); p_segment->style->i_style_flags |= STYLE_UNDERLINE; p_segment->style->i_features |= STYLE_HAS_FLAGS; psz_subtitle++; } } else if( (psz_subtitle[1] == 'C' || psz_subtitle[1] == 'c' ) && psz_subtitle[3] == '$' && i_len >= 7 ) { /* Yes, they use BBGGRR, instead of RRGGBB */ char psz_color[7]; psz_color[0] = psz_subtitle[8]; psz_color[1] = psz_subtitle[9]; psz_color[2] = psz_subtitle[6]; psz_color[3] = psz_subtitle[7]; psz_color[4] = psz_subtitle[4]; psz_color[5] = psz_subtitle[5]; psz_color[6] = '\0'; p_segment = NewTextSegmentPushStyle( p_segment, &p_stack ); p_segment->style->i_font_color = vlc_html_color( psz_color, NULL ); p_segment->style->i_features |= STYLE_HAS_FONT_COLOR; } else if( psz_subtitle[1] == 'F' || psz_subtitle[1] == 'f' ) { p_segment = NewTextSegmentPushStyle( p_segment, &p_stack ); p_segment->style->psz_fontname = strndup( &psz_subtitle[3], i_len ); } else if( psz_subtitle[1] == 'S' || psz_subtitle[1] == 's' ) { int size = atoi( &psz_subtitle[3] ); if( size ) { p_segment = NewTextSegmentPushStyle( p_segment, &p_stack ); p_segment->style->i_font_size = size; p_segment->style->f_font_relsize = STYLE_DEFAULT_REL_FONT_SIZE * STYLE_DEFAULT_FONT_SIZE / p_segment->style->i_font_size; } } /* Currently unsupported since we don't have access to the i_align flag here else if( psz_subtitle[1] == 'P' ) { if( psz_subtitle[3] == "1" ) i_align = SUBPICTURE_ALIGN_TOP; else if( psz_subtitle[3] == "0" ) i_align = SUBPICTURE_ALIGN_BOTTOM; } */ // Hide other {x:y} atrocities, notably {o:x} psz_subtitle = psz_tag_end + 1; } else { if( *psz_subtitle == '\n' || !strncasecmp( psz_subtitle, "\\n", 2 ) ) { if ( !AppendCharacter( p_segment, '\n' ) ) goto fail; if ( *psz_subtitle == '\n' ) psz_subtitle++; else psz_subtitle += 2; } else if( !strncasecmp( psz_subtitle, "\\h", 2 ) ) { if ( !AppendString( p_segment, "\xC2\xA0" ) ) goto fail; psz_subtitle += 2; } else { //FIXME: Highly inneficient AppendCharacter( p_segment, *psz_subtitle ); psz_subtitle++; } } } while ( p_stack ) PopStyle( &p_stack ); while ( p_tag_stack ) { tag_stack_t *p_tag = p_tag_stack; p_tag_stack = p_tag_stack->p_next; free( p_tag->psz_tagname ); free( p_tag ); } return p_first_segment; fail: text_segment_ChainDelete( p_first_segment ); return NULL; }
bool CRoomTemplate::IsBorderRoom() const { return HasTag( "Border" ); }
void TagDictionary :: AddDS( const string & name, TagDictEntry * e ) { if ( HasTag( name, mDSMap ) ) { // flag error somehow } mDSMap.insert( std::make_pair( name, e ) ); }
bool CRoomTemplate::ShouldOnlyPlaceByRequest() const { return HasTag( "Special" ) || HasTag( "Start" ) || HasTag( "Escape" ); }
long CRusSemStructure::GetMNAViolationsCount(long Tag) { long Result = 0; for (size_t NodeNo=0; NodeNo <m_Nodes.size(); NodeNo++) if ( HasTag (NodeNo, Tag) && (m_Nodes[NodeNo].m_NodeType == MNA) ) { long SubordNodes[MaxMNANodesCount]; long SubordNodesCount = 0; bool HasCompAdj = false; bool HasNotCompAdj = false; for (long l=0; l < m_Nodes[NodeNo].m_OutRels.size(); l++) { long RelNo = m_Nodes[NodeNo].m_OutRels[l]; if (!m_Relations[RelNo].m_bRelUse) continue; if (m_Relations[RelNo].m_Valency.m_RelationStr.empty() ) { SubordNodes[SubordNodesCount++] = m_Relations[RelNo].m_TargetNodeNo; assert (SubordNodesCount < MaxMNANodesCount); if (m_Nodes[m_Relations[RelNo].m_TargetNodeNo].m_bCompAdj) HasCompAdj = true; else HasNotCompAdj = true; }; }; /* в однородном ряде не могут быть одновременно сравнительные прил. и что-то от них отличное */ if (HasCompAdj) if (HasNotCompAdj) Result+=60; if (m_Nodes[NodeNo].m_MNAType == CHEMOborot) { Result += GetMNAViolationsCountForChemOborot(*this, NodeNo, SubordNodes, SubordNodesCount); continue; }; if (SubordNodesCount < 2) { Result ++; continue; }; if (m_Nodes[NodeNo].m_MNAType == RepeatMNA) continue; const CRusSemClause& C = m_Clauses[m_Nodes[NodeNo].m_ClauseNo]; // если это простой однородный ряд, то проверими наличие запятых между // составляющими однородного ряда, кроме последнего // (последний разделитель должен быть союз) for (long k=0; k <SubordNodesCount-2; k++) if (!(C.GetGramMatrix(SubordNodes[k],SubordNodes[k+1]) & HaveCommaBetween)) Result++; }; return Result; };
bool CRoomTemplate::IsStartRoom() const { return HasTag( "Start" ); }