@ -2097,7 +2097,7 @@ bool CEntityCL::clipped (const std::vector<NLMISC::CPlane> &clippingPlanes, cons
// Set the name of the entity. Handle replacement tag if any
// Set the name of the entity. Handle replacement tag if any
// to insert NPC task translated.
// to insert NPC task translated.
//---------------------------------------------------
//---------------------------------------------------
void CEntityCL : : setEntityName ( const uc string & name )
void CEntityCL : : setEntityName ( const std: : string & name )
{
{
_EntityName = name ;
_EntityName = name ;
}
}
@ -2264,7 +2264,7 @@ void CEntityCL::load() // virtual
//-----------------------------------------------
//-----------------------------------------------
void CEntityCL : : onStringAvailable ( uint /* stringId */ , const ucstring & value )
void CEntityCL : : onStringAvailable ( uint /* stringId */ , const ucstring & value )
{
{
_EntityName = value ;
_EntityName = value .toUtf8 ( ) ;
// remove the shard name if possible
// remove the shard name if possible
_EntityName = removeShardFromName ( _EntityName ) ;
_EntityName = removeShardFromName ( _EntityName ) ;
@ -2303,7 +2303,7 @@ void CEntityCL::onStringAvailable(uint /* stringId */, const ucstring &value)
if ( pos ! = ucstring : : npos )
if ( pos ! = ucstring : : npos )
{
{
ucstring sn = replacement ;
ucstring sn = replacement ;
_EntityName = STRING_MANAGER: : CStringManagerClient : : getLocalizedName ( sn. substr ( 0 , pos ) ) ;
_EntityName = sn. substr ( 0 , pos ) . toUtf8 ( ) ;
ucstring : : size_type pos2 = sn . find ( ' $ ' , pos + 1 ) ;
ucstring : : size_type pos2 = sn . find ( ' $ ' , pos + 1 ) ;
_TitleRaw = sn . substr ( pos + 1 , pos2 - pos - 1 ) ;
_TitleRaw = sn . substr ( pos + 1 , pos2 - pos - 1 ) ;
replacement = STRING_MANAGER : : CStringManagerClient : : getTitleLocalizedName ( _TitleRaw , womanTitle ) ;
replacement = STRING_MANAGER : : CStringManagerClient : : getTitleLocalizedName ( _TitleRaw , womanTitle ) ;
@ -2370,32 +2370,32 @@ void CEntityCL::onStringAvailable(uint /* stringId */, const ucstring &value)
//-----------------------------------------------
//-----------------------------------------------
// getTitleFromName
// getTitleFromName
//-----------------------------------------------
//-----------------------------------------------
ucstring CEntityCL : : getTitleFromName ( const uc string & name )
std: : string CEntityCL : : getTitleFromName ( const std : : string & name )
{
{
uc string: : size_type p1 = name . find ( ' $ ' ) ;
std: : string: : size_type p1 = name . find ( ' $ ' ) ;
if ( p1 ! = ucstring : : npos )
if ( p1 ! = ucstring : : npos )
{
{
uc string: : size_type p2 = name . find ( ' $ ' , p1 + 1 ) ;
std: : string: : size_type p2 = name . find ( ' $ ' , p1 + 1 ) ;
if ( p2 ! = uc string: : npos )
if ( p2 ! = std: : string: : npos )
return name . substr ( p1 + 1 , p2 - p1 - 1 ) ;
return name . substr ( p1 + 1 , p2 - p1 - 1 ) ;
}
}
return ucstring ( " " ) ;
return std : : string ( ) ;
} // getTitleFromName //
} // getTitleFromName //
//-----------------------------------------------
//-----------------------------------------------
// removeTitleFromName
// removeTitleFromName
//-----------------------------------------------
//-----------------------------------------------
uc string CEntityCL : : removeTitleFromName ( const uc string & name )
std: : string CEntityCL : : removeTitleFromName ( const std: : string & name )
{
{
uc string: : size_type p1 = name . find ( ' $ ' ) ;
std: : string: : size_type p1 = name . find ( ' $ ' ) ;
if ( p1 = = ucstring : : npos )
if ( p1 = = ucstring : : npos )
{
{
return name ;
return name ;
}
}
else
else
{
{
uc string: : size_type p2 = name . find ( ' $ ' , p1 + 1 ) ;
std: : string: : size_type p2 = name . find ( ' $ ' , p1 + 1 ) ;
if ( p2 ! = ucstring : : npos )
if ( p2 ! = ucstring : : npos )
{
{
return name . substr ( 0 , p1 ) + name . substr ( p2 + 1 ) ;
return name . substr ( 0 , p1 ) + name . substr ( p2 + 1 ) ;
@ -2410,16 +2410,16 @@ ucstring CEntityCL::removeTitleFromName(const ucstring &name)
//-----------------------------------------------
//-----------------------------------------------
// removeShardFromName
// removeShardFromName
//-----------------------------------------------
//-----------------------------------------------
uc string CEntityCL : : removeShardFromName ( const uc string & name )
std: : string CEntityCL : : removeShardFromName ( const std: : string & name )
{
{
// The string must contains a '(' and a ')'
// The string must contains a '(' and a ')'
uc string: : size_type p0 = name . find ( ' ( ' ) ;
std: : string: : size_type p0 = name . find ( ' ( ' ) ;
uc string: : size_type p1 = name . find ( ' ) ' ) ;
std: : string: : size_type p1 = name . find ( ' ) ' ) ;
if ( p0 = = ucstring: : npos | | p1 = = uc string: : npos | | p1 < = p0 )
if ( p0 = = std: : string : : npos | | p1 = = std : : string: : npos | | p1 < = p0 )
return name ;
return name ;
// if it is the same as the shard name of the user, remove it
// if it is the same as the shard name of the user, remove it
if ( ucstrnicmp ( name , ( uint ) p0 + 1 , ( uint ) ( p1 - p0 - 1 ), PlayerSelectedHomeShardName )= = 0 )
if ( ! NLMISC : : compareCaseInsensitive ( name . c_str ( ) + p0 + 1 , p1 - p0 - 1 , PlayerSelectedHomeShardName . c_str ( ), PlayerSelectedHomeShardName .size ( ) ) )
return name . substr ( 0 , p0 ) + name . substr ( p1 + 1 ) ;
return name . substr ( 0 , p0 ) + name . substr ( p1 + 1 ) ;
// else don't modify
// else don't modify
else
else
@ -2429,7 +2429,7 @@ ucstring CEntityCL::removeShardFromName(const ucstring &name)
//-----------------------------------------------
//-----------------------------------------------
// removeTitleAndShardFromName
// removeTitleAndShardFromName
//-----------------------------------------------
//-----------------------------------------------
uc string CEntityCL : : removeTitleAndShardFromName ( const uc string & name )
std: : string CEntityCL : : removeTitleAndShardFromName ( const std: : string & name )
{
{
return removeTitleFromName ( removeShardFromName ( name ) ) ;
return removeTitleFromName ( removeShardFromName ( name ) ) ;
}
}