本文整理汇总了C++中Language::AddMsg方法的典型用法代码示例。如果您正苦于以下问题:C++ Language::AddMsg方法的具体用法?C++ Language::AddMsg怎么用?C++ Language::AddMsg使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Language
的用法示例。
在下文中一共展示了Language::AddMsg方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ParseSection
//.........这里部分代码省略.........
else if ( key == "icon" ) t.SetImage( StrToNum( val ) );
else if ( key == "armour" ) t.SetDefence( StrToNum( val ) );
else if ( key == "speed" ) t.SetMoves( StrToNum( val ) );
else if ( key == "price" ) t.SetCost( StrToNum( val ) );
else if ( key == "weight" ) t.SetWeight( StrToNum( val ) );
else if ( key == "transslots" ) t.SetTransSlots( StrToNum( val ) );
else if ( key == "transminweight" ) t.SetTransMinWeight( StrToNum( val ) );
else if ( key == "transmaxweight" ) t.SetTransMaxWeight( StrToNum( val ) );
else if ( key == "portrait" ) {
vector<string>::iterator it =
find( info.portraits.begin(), info.portraits.end(), val );
if ( it == info.portraits.end() ) {
t.SetPortrait( info.portraits.size() );
info.portraits.push_back( val );
} else {
t.SetPortrait( distance( info.portraits.begin(), it ) );
}
}
else if ( key.substr( 0, 5 ) == "power" ) {
string type = ParseOpt( key );
if ( type == "" ) rc = 1;
else rc = ParsePower( val, type, t );
}
else if ( key.substr( 0, 4 ) == "name" ) {
string lang = ParseOpt( key );
if ( lang == "" ) rc = 1;
else if ( lang.size() != 2 ) {
rc = 1;
cerr << "Error near line " << line << ": '" << val << "' is not a valid language" << endl;
} else {
map <string, Language>::iterator it = names.find( lang );
if ( it == names.end() ) {
// only accept new languages for the first unit
if ( units.size() == 0 ) {
Language l;
l.SetID( lang.c_str() );
l.AddMsg( val );
names[lang] = l;
named = true;
} else
cerr << "Warning near line " << line << ": New language '" << lang << "' ignored" << endl;
} else {
it->second.AddMsg( val );
named = true;
}
}
} else {
rc = 1;
cerr << "Error near line " << line << ": Invalid keyword '" << key << "' in this context" << endl;
}
}
if ( t.Firepower( U_GROUND ) == 0 ) {
t.SetMinRangeGround( 0 );
t.SetMaxRangeGround( 0 );
}
if ( t.Firepower( U_SHIP ) == 0 ) {
t.SetMinRangeShip( 0 );
t.SetMaxRangeShip( 0 );
}
if ( t.Firepower( U_AIR ) == 0 ) {
t.SetMinRangeAir( 0 );
t.SetMaxRangeAir( 0 );
}
if ( t.Slots() > 0 ) t.AddFlags( U_TRANSPORT );
if ( t.Terrain() == 0 ) {
rc = 1;
cerr << "Error near line " << line << ": Unit does not specify terrain" << endl;
}
if ( !named ) {
rc = 1;
cerr << "Error near line " << line << ": Unit does not specify a name" << endl;
} else {
unsigned short msgs = names[CF_LANG_DEFAULT].Size();
for ( map<string, Language>::iterator it = names.begin();
it != names.end(); ++it ) {
if ( it->second.Size() != msgs ) {
const char *defname = names[CF_LANG_DEFAULT].GetMsg(msgs-1);
if ( defname ) {
cerr << "Warning near line " << line
<< ": Unit does not specify name for language '" << it->first
<< "', using '" << CF_LANG_DEFAULT << "' default ("
<< defname << ')' << endl;
it->second.AddMsg( defname );
} else {
rc = 1;
cerr << "Error near line " << line
<< ": Unit does not specify name for language '" << it->first << "'" << endl;
}
}
}
}
units.push_back( t );
}
return rc;
}