@ -39,17 +39,17 @@ namespace STRING_MANAGER
// ***************************************************************************
map < string , CStringManagerClient : : CItem > CStringManagerClient : : _SpecItem_TempMap ;
map < uc string, uc string> CStringManagerClient : : _DynStrings ;
vector < uc string> CStringManagerClient : : _TitleWords ;
map < string, string> CStringManagerClient : : _DynStrings ;
vector < string> CStringManagerClient : : _TitleWords ;
bool CStringManagerClient : : _SpecItem_MemoryCompressed = false ;
char * CStringManagerClient : : _SpecItem_Labels = NULL ;
uc char * CStringManagerClient : : _SpecItem_NameDesc = NULL ;
char * CStringManagerClient : : _SpecItem_NameDesc = NULL ;
vector < CStringManagerClient : : CItemLight > CStringManagerClient : : _SpecItems ;
bool MustReleaseStaticArrays = true ;
CStringManagerClient * CStringManagerClient : : _Instance = NULL ;
uc string CStringManagerClient : : _WaitString ( " ??? " ) ;
string CStringManagerClient : : _WaitString ( " ??? " ) ;
CStringManagerClient : : CStringManagerClient ( )
@ -57,7 +57,7 @@ namespace STRING_MANAGER
_CacheInited = false ;
_CacheLoaded = false ;
// insert the empty string.
_ReceivedStrings . insert ( make_pair ( ( uint ) EmptyStringId , uc string( ) ) ) ;
_ReceivedStrings . insert ( make_pair ( ( uint ) EmptyStringId , string( ) ) ) ;
// reserve some place to avoid reallocation as possible
_CacheStringToSave . reserve ( 1024 ) ;
}
@ -99,7 +99,7 @@ namespace STRING_MANAGER
}
}
void CStringManagerClient : : initCache ( const st d: : st ring & languageCode )
void CStringManagerClient : : initCache ( const st ring & languageCode )
{
H_AUTO ( CStringManagerClient_initLanguage )
@ -112,7 +112,7 @@ namespace STRING_MANAGER
// NB : we keep the waiting strings and dyn strings
// insert the empty string.
_ReceivedStrings . insert ( make_pair ( ( uint ) EmptyStringId , uc string( ) ) ) ;
_ReceivedStrings . insert ( make_pair ( ( uint ) EmptyStringId , string( ) ) ) ;
// to be inited, language code must be filled
_CacheInited = ! m_LanguageCode . empty ( ) ;
@ -128,8 +128,10 @@ namespace STRING_MANAGER
{
try
{
std : : string clientApp = ClientCfg . ConfigFile . getVar ( " Application " ) . asString ( 0 ) ;
_CacheFilename = std : : string ( " save/ " ) + clientApp + " _ " + toString ( shardId ) + " _ " + m_LanguageCode + " .string_cache " ;
const uint currentVersion = 1 ;
string clientApp = ClientCfg . ConfigFile . getVar ( " Application " ) . asString ( 0 ) ;
_CacheFilename = string ( " save/ " ) + clientApp + " _ " + toString ( shardId ) + " _ " + m_LanguageCode + " .string_cache " ;
nlinfo ( " SM : Try to open the string cache : %s " , _CacheFilename . c_str ( ) ) ;
@ -138,6 +140,8 @@ namespace STRING_MANAGER
// there is a cache file, check date reset it if needed
{
NLMISC : : CIFile file ( _CacheFilename ) ;
file . setVersionException ( false , false ) ;
file . serialVersion ( currentVersion ) ;
file . serial ( _Timestamp ) ;
}
@ -146,6 +150,7 @@ namespace STRING_MANAGER
nlinfo ( " SM: Clearing string cache : outofdate " ) ;
// the cache is not sync, reset it
NLMISC : : COFile file ( _CacheFilename ) ;
file . serialVersion ( currentVersion ) ;
file . serial ( timestamp ) ;
}
else
@ -158,6 +163,7 @@ namespace STRING_MANAGER
nlinfo ( " SM: Creating string cache " ) ;
// cache file don't exist, create it with the timestamp
NLMISC : : COFile file ( _CacheFilename ) ;
file . serialVersion ( currentVersion ) ;
file . serial ( timestamp ) ;
}
@ -168,17 +174,19 @@ namespace STRING_MANAGER
// NB : we keep the waiting strings and dyn strings
// insert the empty string.
_ReceivedStrings . insert ( make_pair ( ( uint ) EmptyStringId , uc string( ) ) ) ;
_ReceivedStrings . insert ( make_pair ( ( uint ) EmptyStringId , string( ) ) ) ;
// load the cache file
NLMISC : : CIFile file ( _CacheFilename ) ;
int version = file . serialVersion ( currentVersion ) ;
file . serial ( _Timestamp ) ;
nlassert ( _Timestamp = = timestamp ) ;
nlassert ( version > = 1 ) ; // Initial version
while ( ! file . eof ( ) )
{
uint32 id ;
uc string str ;
string str ;
file . serial ( id ) ;
file . serial ( str ) ;
@ -202,12 +210,12 @@ namespace STRING_MANAGER
void CStringManagerClient : : waitString ( uint32 stringId , const IStringWaiterRemover * premover , uc string * result )
void CStringManagerClient : : waitString ( uint32 stringId , const IStringWaiterRemover * premover , string * result )
{
H_AUTO ( CStringManagerClient_waitString )
nlassert ( premover & & result ) ;
uc string value ;
string value ;
if ( getString ( stringId , value ) )
* result = value ;
else
@ -225,7 +233,7 @@ namespace STRING_MANAGER
H_AUTO ( CStringManagerClient_waitString2 )
nlassert ( pcallback ! = 0 ) ;
uc string value ;
string value ;
if ( getString ( stringId , value ) )
{
pcallback - > onStringAvailable ( stringId , value ) ;
@ -238,12 +246,12 @@ namespace STRING_MANAGER
}
void CStringManagerClient : : waitDynString ( uint32 stringId , const IStringWaiterRemover * premover , uc string * result )
void CStringManagerClient : : waitDynString ( uint32 stringId , const IStringWaiterRemover * premover , string * result )
{
H_AUTO ( CStringManagerClient_waitDynString )
nlassert ( premover & & result ) ;
uc string value ;
string value ;
if ( getDynString ( stringId , value ) )
* result = value ;
else
@ -261,7 +269,7 @@ namespace STRING_MANAGER
H_AUTO ( CStringManagerClient_waitDynString2 )
nlassert ( pcallback ! = 0 ) ;
uc string value ;
string value ;
if ( getDynString ( stringId , value ) )
{
pcallback - > onDynStringAvailable ( stringId , value ) ;
@ -338,7 +346,7 @@ restartLoop4:
bool CStringManagerClient : : getString ( uint32 stringId , uc string & result )
bool CStringManagerClient : : getString ( uint32 stringId , string & result )
{
H_AUTO ( CStringManagerClient_getString )
@ -365,7 +373,7 @@ restartLoop4:
_WaitingStrings . insert ( stringId ) ;
// need to ask for this string.
NLMISC : : CBitMemStream bms ;
const st d: : st ring msgType = " STRING_MANAGER:STRING_RQ " ;
const st ring msgType = " STRING_MANAGER:STRING_RQ " ;
if ( GenericMsgHeaderMngr . pushNameToStream ( msgType , bms ) )
{
bms . serial ( stringId ) ;
@ -382,7 +390,7 @@ restartLoop4:
{
char tmp [ 1024 ] ;
sprintf ( tmp , " <WAIT STR %u> " , stringId ) ;
result = ucstring( tmp) ;
result = tmp;
}
else
result . erase ( ) ; // = _WaitString;
@ -393,14 +401,14 @@ restartLoop4:
{
char tmp [ 1024 ] ;
sprintf ( tmp , " <STR %u> " , stringId ) ;
result = ucstring( tmp) + it - > second ;
result = tmp + it - > second ;
}
else
{
result = it - > second ;
if ( result . size ( ) > 9 & & result . substr ( 0 , 9 ) = = ucstring ( " <missing: " ) )
if ( result . size ( ) > 9 & & result . substr ( 0 , 9 ) = = " <missing: " )
{
map < uc string, uc string> : : iterator itds = _DynStrings . find ( result . substr ( 9 , result . size ( ) - 10 ) ) ;
map < string, string> : : iterator itds = _DynStrings . find ( result . substr ( 9 , result . size ( ) - 10 ) ) ;
if ( itds ! = _DynStrings . end ( ) )
result = itds - > second ;
}
@ -410,7 +418,7 @@ restartLoop4:
return true ;
}
void CStringManagerClient : : receiveString ( uint32 stringId , const uc string & str )
void CStringManagerClient : : receiveString ( uint32 stringId , const string & str )
{
H_AUTO ( CStringManagerClient_receiveString )
@ -427,8 +435,8 @@ restartLoop4:
TStringsContainer : : iterator it ( _ReceivedStrings . find ( stringId ) ) ;
nlwarning ( " Receiving stringID %u (%s), already in received string (%s), replacing with new value. " ,
stringId ,
str . toString( ) . c_str( ) ,
it - > second . toString( ) . c_str( ) ) ;
str . c_str( ) ,
it - > second . c_str( ) ) ;
if ( it - > second ! = str )
it - > second = str ;
@ -492,7 +500,7 @@ restartLoop:
last = _WaitingDynStrings . end ( ) ;
for ( ; first ! = last ; + + first )
{
uc string value ;
string value ;
uint number = first - > first ;
/// Warning: if getDynString() return true, 'first' is erased => don't use it after in this loop
if ( getDynString ( number , value ) )
@ -624,7 +632,7 @@ restartLoop:
return false ;
}
// ok, we have the base string, we can serial the parameters
uc string: : iterator first ( dynInfo . String . begin ( ) ) , last ( dynInfo . String . end ( ) ) ;
string: : iterator first ( dynInfo . String . begin ( ) ) , last ( dynInfo . String . end ( ) ) ;
for ( ; first ! = last ; + + first )
{
if ( * first = = ' % ' )
@ -707,10 +715,10 @@ restartLoop:
if ( dynInfo . Status = = TDynStringInfo : : serialized )
{
// try to retreive all string parameter to build the string.
uc string temp ;
string temp ;
temp . reserve ( dynInfo . String . size ( ) * 2 ) ;
uc string: : iterator src ( dynInfo . String . begin ( ) ) ;
uc string: : iterator move = src ;
string: : iterator src ( dynInfo . String . begin ( ) ) ;
string: : iterator move = src ;
std : : vector < TParamValue > : : iterator first ( dynInfo . Params . begin ( ) ) , last ( dynInfo . Params . end ( ) ) ;
for ( ; first ! = last ; + + first )
@ -720,7 +728,7 @@ restartLoop:
{
case string_id :
{
uc string str ;
string str ;
if ( ! getString ( param . StringId , str ) )
return false ;
@ -736,14 +744,14 @@ restartLoop:
// If the shard name is the same as the player home shard name, remove it
uint len = ( uint ) PlayerSelectedHomeShardNameWithParenthesis . size ( ) ;
uint start = ( uint ) str . size ( ) - len ;
if ( ucstrnicmp ( str , start , len , PlayerSelectedHomeShardNameWithParenthesis ) = = 0 )
if ( ucstrnicmp ( str , start , len , PlayerSelectedHomeShardNameWithParenthesis ) = = 0 ) // TODO: NLMISC::compareCaseInsensitive
str . resize ( start ) ;
}
}
}
// If the string contains a title, then remove it
uc string: : size_type pos = str . find ( ' $ ' ) ;
string: : size_type pos = str . find ( ' $ ' ) ;
if ( ! str . empty ( ) & & pos ! = ucstring : : npos )
{
str = CEntityCL : : removeTitleFromName ( str ) ;
@ -761,13 +769,13 @@ restartLoop:
char value [ 1024 ] ;
sprintf ( value , " %d " , param . Integer ) ;
temp . append ( move , src + param . ReplacementPoint ) ;
temp + = ucstring ( value ) ;
temp + = value ;
move = dynInfo . String . begin ( ) + param . ReplacementPoint + 2 ;
}
break ;
case time :
{
uc string value ;
string value ;
uint32 time = ( uint32 ) param . Time ;
if ( time > = ( 10 * 60 * 60 ) )
{
@ -798,7 +806,7 @@ restartLoop:
char value [ 1024 ] ;
sprintf ( value , " %u " , ( uint32 ) param . Money ) ;
temp . append ( move , src + param . ReplacementPoint ) ;
temp + = ucstring ( value ) ;
temp + = value ;
move = dynInfo . String . begin ( ) + param . ReplacementPoint + 2 ;
}
// TODO
@ -807,7 +815,7 @@ restartLoop:
break ;
case dyn_string_id :
{
uc string dynStr ;
string dynStr ;
if ( ! getDynString ( param . DynStringId , dynStr ) )
return false ;
temp . append ( move , src + param . ReplacementPoint ) ;
@ -825,8 +833,8 @@ restartLoop:
// apply any 'delete' character in the string and replace double '%'
{
uin t i = 0 ;
while ( i < temp . size ( ) )
ptrdiff_ t i = 0 ;
while ( i < ( ptrdiff_t ) temp . size ( ) )
{
if ( temp [ i ] = = 8 )
{
@ -855,7 +863,7 @@ restartLoop:
}
bool CStringManagerClient : : getDynString ( uint32 dynStringId , uc string & result )
bool CStringManagerClient : : getDynString ( uint32 dynStringId , std: : string & result )
{
H_AUTO ( CStringManagerClient_getDynString )
@ -884,7 +892,7 @@ restartLoop:
{
char tmp [ 1024 ] ;
sprintf ( tmp , " <DYNSTR %u> " , dynStringId ) ;
result = ucstring( tmp) + it - > second . String ;
result = tmp + it - > second . String ;
}
else
result = it - > second . String ;
@ -910,7 +918,7 @@ restartLoop:
nlwarning ( " DynStringID %u is unknown ! " , dynStringId ) ;
char tmp [ 1024 ] ;
sprintf ( tmp , " <UNKNOWN DYNSTR %u> " , dynStringId ) ;
result = ucstring( tmp) ;
result = tmp;
}
else
result . erase ( ) ; //_WaitString;
@ -922,7 +930,7 @@ restartLoop:
{
char tmp [ 1024 ] ;
sprintf ( tmp , " <DYNSTR %u> " , dynStringId ) ;
result = ucstring( tmp) + it - > second . String ;
result = tmp + it - > second . String ;
}
else
result = it - > second . String ;
@ -935,7 +943,7 @@ restartLoop:
{
char tmp [ 1024 ] ;
sprintf ( tmp , " <WAIT DYNSTR %u> " , dynStringId ) ;
result = ucstring( tmp) ;
result = tmp;
}
else
result . erase ( ) ; // = _WaitString;
@ -945,7 +953,7 @@ restartLoop:
}
// Tool fct to lookup a reference file
static string lookupReferenceFile ( const st d: : st ring & fileName )
static string lookupReferenceFile ( const st ring & fileName )
{
string referenceFile ;
// special location for the "wk" language
@ -966,14 +974,14 @@ restartLoop:
return referenceFile ;
}
void CLoadProxy : : loadStringFile ( const st d: : st ring & filename , ucstring & text )
void CLoadProxy : : loadStringFile ( const st ring & filename , ucstring & text )
{
vector < TStringInfo > reference ;
vector < TStringInfo > addition ;
vector < TStringInfo > diff ;
// get the correct path name of the ref file
st d: : st ring referenceFile = lookupReferenceFile ( filename ) ;
st ring referenceFile = lookupReferenceFile ( filename ) ;
// load the reference file
if ( ! referenceFile . empty ( ) )
@ -1043,7 +1051,7 @@ public:
TWorksheet diff ;
// get the correct path name of the ref file
st d: : st ring referenceFile = lookupReferenceFile ( filename ) ;
st ring referenceFile = lookupReferenceFile ( filename ) ;
// load the reference file
if ( ! referenceFile . empty ( ) )
@ -1136,7 +1144,7 @@ public:
const string StringClientPackedFileName = " ./save/string_client.pack " ;
// Must Increment this number if change are made to the code (else change not taken into account)
const uint StringClientPackedVersion = 0 ;
bool CStringManagerClient : : checkWordFileDates ( vector < CFileCheck > & fileChecks , const std : : vector < st d: : st ring> & fileNames , const std : : string & languageCode )
bool CStringManagerClient : : checkWordFileDates ( vector < CFileCheck > & fileChecks , const std : : vector < st ring> & fileNames , const string & languageCode )
{
fileChecks . resize ( fileNames . size ( ) ) ;
@ -1144,7 +1152,7 @@ bool CStringManagerClient::checkWordFileDates(vector<CFileCheck> &fileChecks, co
for ( uint i = 0 ; i < fileChecks . size ( ) ; i + + )
{
// get the correct path name of the ref file
st d: : st ring referenceFile = lookupReferenceFile ( fileNames [ i ] ) ;
st ring referenceFile = lookupReferenceFile ( fileNames [ i ] ) ;
fileChecks [ i ] . ReferenceDate = referenceFile . empty ( ) ? 0 : CFile : : getFileModificationDate ( referenceFile ) ;
// get then one of the working File (NB: 0 is a valid reponse for Final Client: no working file)
@ -1171,7 +1179,7 @@ bool CStringManagerClient::checkWordFileDates(vector<CFileCheck> &fileChecks, co
// ***************************************************************************
void CStringManagerClient : : initI18NSpecialWords ( const st d: : st ring & languageCode )
void CStringManagerClient : : initI18NSpecialWords ( const st ring & languageCode )
{
ucstring womenNameColIdent = string ( " women_name " ) ;
ucstring descColIdent = string ( " description " ) ;
@ -1215,8 +1223,8 @@ void CStringManagerClient::initI18NSpecialWords(const std::string &languageCode)
uint32 profile0 = ( uint32 ) ryzomGetLocalTime ( ) ;
ucstring ucs ;
st d: : st ring fileName = fileNames [ i ] ;
st d: : st ring keyExtenstion = specialWords [ i * 3 + 2 ] ;
st ring fileName = fileNames [ i ] ;
st ring keyExtenstion = specialWords [ i * 3 + 2 ] ;
// read the ucstring and make diffs with data in ./translation/work.
CReadWorkSheetFile rwsf ;
@ -1252,17 +1260,17 @@ void CStringManagerClient::initI18NSpecialWords(const std::string &languageCode)
for ( uint j = 1 ; j < ws . size ( ) ; j + + )
{
// Get the key and name string.
const uc string & key = ws . getData ( j , keyColIndex ) ;
const uc string & name = ws . getData ( j , nameColIndex ) ;
const string & key = ws . getData ( j , keyColIndex ) . toUtf8 ( ) ;
const string & name = ws . getData ( j , nameColIndex ) . toUtf8 ( ) ;
// Append to the I18N.
// avoid case problems
string keyStr = NLMISC : : toLower ( key . toString ( ) ) ;
string keyStr = NLMISC : : toLower ( key ) ;
// append the special key extension.
keyStr + = keyExtenstion ;
// insert in map.
std : : map < st d: : st ring, CItem > : : iterator it ;
std : : map < st ring, CItem > : : iterator it ;
it = _SpecItem_TempMap . find ( keyStr ) ;
if ( it ! = _SpecItem_TempMap . end ( ) )
{
@ -1278,7 +1286,7 @@ void CStringManagerClient::initI18NSpecialWords(const std::string &languageCode)
if ( womenNameColIndex ! = std : : numeric_limits < uint > : : max ( ) )
{
const ucstring & womenName = ws . getData ( j , womenNameColIndex ) ;
_SpecItem_TempMap [ keyStr ] . WomenName = womenName ;
_SpecItem_TempMap [ keyStr ] . WomenName = womenName .toUtf8 ( ) ;
// replace all \n in the women name with true \n
while ( strFindReplace ( _SpecItem_TempMap [ keyStr ] . WomenName , " \\ n " , " \n " ) ) ;
}
@ -1287,7 +1295,7 @@ void CStringManagerClient::initI18NSpecialWords(const std::string &languageCode)
if ( descColIndex ! = std : : numeric_limits < uint > : : max ( ) )
{
const ucstring & desc = ws . getData ( j , descColIndex ) ;
_SpecItem_TempMap [ keyStr ] . Desc = desc ;
_SpecItem_TempMap [ keyStr ] . Desc = desc .toUtf8 ( ) ;
// replace all \n in the desc with true \n
while ( strFindReplace ( _SpecItem_TempMap [ keyStr ] . Desc , " \\ n " , " \n " ) ) ;
}
@ -1296,7 +1304,7 @@ void CStringManagerClient::initI18NSpecialWords(const std::string &languageCode)
if ( descColIndex2 ! = std : : numeric_limits < uint > : : max ( ) )
{
const ucstring & desc = ws . getData ( j , descColIndex2 ) ;
_SpecItem_TempMap [ keyStr ] . Desc2 = desc ;
_SpecItem_TempMap [ keyStr ] . Desc2 = desc .toUtf8 ( ) ;
// replace all \n in the desc with true \n
while ( strFindReplace ( _SpecItem_TempMap [ keyStr ] . Desc2 , " \\ n " , " \n " ) ) ;
}
@ -1360,7 +1368,7 @@ void CStringManagerClient::specialWordsMemoryCompress()
// Make big strings
_SpecItems . resize ( nNbEntries ) ;
_SpecItem_Labels = new char [ nLabelSize ] ;
_SpecItem_NameDesc = new uc char[ nNameDescSize ] ;
_SpecItem_NameDesc = new char[ nNameDescSize ] ;
nNbEntries = 0 ;
nLabelSize = 0 ;
@ -1368,35 +1376,30 @@ void CStringManagerClient::specialWordsMemoryCompress()
it = _SpecItem_TempMap . begin ( ) ;
while ( it ! = _SpecItem_TempMap . end ( ) )
{
if ( strnicmp ( it - > first . c_str ( ) , " bf " , 2 ) = = 0 )
if ( NLMISC : : startsWith ( it - > first . c_str ( ) , " bf " ) )
{
uint nDbg = 0 ;
nDbg + + ;
}
_SpecItems [ nNbEntries ] . Label = _SpecItem_Labels + nLabelSize ;
strcpy ( _SpecItem s[ nNbEntries ] . Label , it - > first . c_str ( ) ) ;
strcpy ( _SpecItem _Labels+ nLabelSize , it - > first . c_str ( ) ) ;
nLabelSize + = ( uint32 ) it - > first . size ( ) + 1 ;
_SpecItems [ nNbEntries ] . Name = _SpecItem_NameDesc + nNameDescSize ;
memcpy ( _SpecItems [ nNbEntries ] . Name , it - > second . Name . c_str ( ) , 2 * ( it - > second . Name . size ( ) + 1 ) ) ;
_SpecItems [ nNbEntries ] . Name [ it - > second . Name . size ( ) ] = 0 ;
strcpy ( _SpecItem_NameDesc + nNameDescSize , it - > second . Name . c_str ( ) ) ;
nNameDescSize + = ( uint32 ) it - > second . Name . size ( ) + 1 ;
_SpecItems [ nNbEntries ] . WomenName = _SpecItem_NameDesc + nNameDescSize ;
memcpy ( _SpecItems [ nNbEntries ] . WomenName , it - > second . WomenName . c_str ( ) , 2 * ( it - > second . WomenName . size ( ) + 1 ) ) ;
_SpecItems [ nNbEntries ] . WomenName [ it - > second . WomenName . size ( ) ] = 0 ;
strcpy ( _SpecItem_NameDesc + nNameDescSize , it - > second . WomenName . c_str ( ) ) ;
nNameDescSize + = ( uint32 ) it - > second . WomenName . size ( ) + 1 ;
_SpecItems [ nNbEntries ] . Desc = _SpecItem_NameDesc + nNameDescSize ;
memcpy ( _SpecItems [ nNbEntries ] . Desc , it - > second . Desc . c_str ( ) , 2 * ( it - > second . Desc . size ( ) + 1 ) ) ;
_SpecItems [ nNbEntries ] . Desc [ it - > second . Desc . size ( ) ] = 0 ;
strcpy ( _SpecItem_NameDesc + nNameDescSize , it - > second . Desc . c_str ( ) ) ;
nNameDescSize + = ( uint32 ) it - > second . Desc . size ( ) + 1 ;
_SpecItems [ nNbEntries ] . Desc2 = _SpecItem_NameDesc + nNameDescSize ;
memcpy ( _SpecItems [ nNbEntries ] . Desc2 , it - > second . Desc2 . c_str ( ) , 2 * ( it - > second . Desc2 . size ( ) + 1 ) ) ;
_SpecItems [ nNbEntries ] . Desc2 [ it - > second . Desc2 . size ( ) ] = 0 ;
strcpy ( _SpecItem_NameDesc + nNameDescSize , it - > second . Desc2 . c_str ( ) ) ;
nNameDescSize + = ( uint32 ) it - > second . Desc2 . size ( ) + 1 ;
nNbEntries + + ;
@ -1408,23 +1411,23 @@ void CStringManagerClient::specialWordsMemoryCompress()
}
// ***************************************************************************
const ucchar * CStringManagerClient : : getSpecialWord ( const std : : string & label , bool women )
const char * CStringManagerClient : : getSpecialWord ( const string & label , bool women )
{
if ( label . empty ( ) )
{
static uc string emptyString ;
static string emptyString ;
return emptyString . c_str ( ) ;
}
if ( label [ 0 ] = = ' # ' )
{
static uc string rawString ;
static string rawString ;
rawString = label . substr ( 1 , label . size ( ) - 1 ) ;
return rawString . c_str ( ) ;
}
// avoid case problems
static st d: : st ring lwrLabel ;
static st ring lwrLabel ;
lwrLabel = toLower ( label ) ;
if ( _SpecItem_MemoryCompressed )
@ -1459,28 +1462,26 @@ const ucchar * CStringManagerClient::getSpecialWord(const std::string &label, bo
}
}
static ucstring badString ;
badString = ucstring ( std : : string ( " <NotExist: " ) + lwrLabel + " > " ) ;
static string badString ;
badString = " <NotExist: " + lwrLabel + " > " ;
return badString . c_str ( ) ;
}
// ***************************************************************************
const ucchar * CStringManagerClient : : getSpecialDesc ( const std : : string & label )
const char * CStringManagerClient : : getSpecialDesc ( const string & label )
{
static ucstring emptyString ;
static string emptyString ;
if ( label . empty ( ) )
return emptyString . c_str ( ) ;
// avoid case problems
static st d: : string lwrLabel ;
static st ring lwrLabel ;
lwrLabel = toLower ( label ) ;
if ( _SpecItem_MemoryCompressed )
{
CItemLight tmp ;
tmp . Label = ( char * ) lwrLabel . c_str ( ) ;
tmp . Label = lwrLabel . c_str ( ) ;
vector < CItemLight > : : iterator it = lower_bound ( _SpecItems . begin ( ) , _SpecItems . end ( ) , tmp , CItemLightComp ( ) ) ;
if ( it ! = _SpecItems . end ( ) )
@ -1500,20 +1501,20 @@ const ucchar * CStringManagerClient::getSpecialDesc(const std::string &label)
}
// ***************************************************************************
const ucchar * CStringManagerClient : : getSpecialDesc2 ( const std : : string & label )
const char * CStringManagerClient : : getSpecialDesc2 ( const string & label )
{
static ucstring emptyString ;
static string emptyString ;
if ( label . empty ( ) )
return emptyString . c_str ( ) ;
// avoid case problems
static st d: : string lwrLabel ;
static st ring lwrLabel ;
lwrLabel = toLower ( label ) ;
if ( _SpecItem_MemoryCompressed )
{
CItemLight tmp ;
tmp . Label = ( char * ) lwrLabel . c_str ( ) ;
tmp . Label = lwrLabel . c_str ( ) ;
vector < CItemLight > : : iterator it = lower_bound ( _SpecItems . begin ( ) , _SpecItems . end ( ) , tmp , CItemLightComp ( ) ) ;
if ( it ! = _SpecItems . end ( ) )
@ -1542,87 +1543,87 @@ const ucchar * CStringManagerClient::getSpecialDesc2(const std::string &label)
*/
// ***************************************************************************
const uc char * CStringManagerClient : : getPlaceLocalizedName ( const string & placeNameID )
const char * CStringManagerClient : : getPlaceLocalizedName ( const string & placeNameID )
{
return getSpecialWord ( placeNameID ) ;
}
// ***************************************************************************
const uc char * CStringManagerClient : : getFactionLocalizedName ( const string & factionNameID )
const char * CStringManagerClient : : getFactionLocalizedName ( const string & factionNameID )
{
return getSpecialWord ( factionNameID ) ;
}
// ***************************************************************************
const uc char * CStringManagerClient : : getSkillLocalizedName ( SKILLS : : ESkills e )
const char * CStringManagerClient : : getSkillLocalizedName ( SKILLS : : ESkills e )
{
return getSpecialWord ( SKILLS : : toString ( e ) ) ;
}
// ***************************************************************************
const uc char * CStringManagerClient : : getItemLocalizedName ( CSheetId id )
const char * CStringManagerClient : : getItemLocalizedName ( CSheetId id )
{
return getSpecialWord ( id . toString ( ) ) ;
}
// ***************************************************************************
const uc char * CStringManagerClient : : getCreatureLocalizedName ( NLMISC : : CSheetId id )
const char * CStringManagerClient : : getCreatureLocalizedName ( NLMISC : : CSheetId id )
{
return getSpecialWord ( id . toString ( ) ) ;
}
// ***************************************************************************
const uc char * CStringManagerClient : : getSBrickLocalizedName ( NLMISC : : CSheetId id )
const char * CStringManagerClient : : getSBrickLocalizedName ( NLMISC : : CSheetId id )
{
return getSpecialWord ( id . toString ( ) ) ;
}
// ***************************************************************************
const uc char * CStringManagerClient : : getSPhraseLocalizedName ( NLMISC : : CSheetId id )
const char * CStringManagerClient : : getSPhraseLocalizedName ( NLMISC : : CSheetId id )
{
return getSpecialWord ( id . toString ( ) ) ;
}
// ***************************************************************************
/*const uc char *CStringManagerClient::getBrickLocalizedDescription(BRICK_FAMILIES::TBrickFamily e)
/*const char *CStringManagerClient::getBrickLocalizedDescription(BRICK_FAMILIES::TBrickFamily e)
{
return getSpecialDesc ( BRICK_FAMILIES : : toString ( e ) ) ;
}
*/
// ***************************************************************************
const uc char * CStringManagerClient : : getSkillLocalizedDescription ( SKILLS : : ESkills e )
const char * CStringManagerClient : : getSkillLocalizedDescription ( SKILLS : : ESkills e )
{
return getSpecialDesc ( SKILLS : : toString ( e ) ) ;
}
// ***************************************************************************
const uc char * CStringManagerClient : : getItemLocalizedDescription ( CSheetId id )
const char * CStringManagerClient : : getItemLocalizedDescription ( CSheetId id )
{
return getSpecialDesc ( id . toString ( ) ) ;
}
// ***************************************************************************
const uc char * CStringManagerClient : : getSBrickLocalizedDescription ( NLMISC : : CSheetId id )
const char * CStringManagerClient : : getSBrickLocalizedDescription ( NLMISC : : CSheetId id )
{
return getSpecialDesc ( id . toString ( ) ) ;
}
// ***************************************************************************
const uc char * CStringManagerClient : : getSBrickLocalizedCompositionDescription ( NLMISC : : CSheetId id )
const char * CStringManagerClient : : getSBrickLocalizedCompositionDescription ( NLMISC : : CSheetId id )
{
return getSpecialDesc2 ( id . toString ( ) ) ;
}
// ***************************************************************************
const uc char * CStringManagerClient : : getSPhraseLocalizedDescription ( NLMISC : : CSheetId id )
const char * CStringManagerClient : : getSPhraseLocalizedDescription ( NLMISC : : CSheetId id )
{
return getSpecialDesc ( id . toString ( ) ) ;
}
// ***************************************************************************
const uc char * CStringManagerClient : : getTitleLocalizedName ( const uc string & titleId , bool women )
const char * CStringManagerClient : : getTitleLocalizedName ( const string & titleId , bool women )
{
vector < uc string> listInfos = getTitleInfos ( titleId , women ) ;
vector < string> listInfos = getTitleInfos ( titleId , women ) ;
if ( ! listInfos . empty ( ) )
{
@ -1634,18 +1635,18 @@ const ucchar *CStringManagerClient::getTitleLocalizedName(const ucstring &titleI
}
// ***************************************************************************
vector < uc string> CStringManagerClient : : getTitleInfos ( const uc string & titleId , bool women )
vector < string> CStringManagerClient : : getTitleInfos ( const string & titleId , bool women )
{
//ucstring infosUC;
//infosUC.fromUtf8(titleId);
vector < uc string> listInfos ;
split UC String( titleId , uc string( " # " ) , listInfos ) ;
vector < string> listInfos ;
split String( titleId , string( " # " ) , listInfos ) ;
if ( ! listInfos . empty ( ) )
{
if ( titleId [ 0 ] ! = ' # ' )
{
listInfos [ 0 ] = getSpecialWord ( listInfos [ 0 ] .toUtf8 ( ) , women ) ;
listInfos [ 0 ] = getSpecialWord ( listInfos [ 0 ] , women ) ;
}
}
@ -1653,74 +1654,76 @@ vector<ucstring> CStringManagerClient::getTitleInfos(const ucstring &titleId, bo
}
// ***************************************************************************
const uc char * CStringManagerClient : : getClassificationTypeLocalizedName ( EGSPD : : CClassificationType : : TClassificationType type )
const char * CStringManagerClient : : getClassificationTypeLocalizedName ( EGSPD : : CClassificationType : : TClassificationType type )
{
return getSpecialDesc ( EGSPD : : CClassificationType : : toString ( type ) ) ;
}
// ***************************************************************************
const uc char * CStringManagerClient : : getOutpostLocalizedName ( NLMISC : : CSheetId id )
const char * CStringManagerClient : : getOutpostLocalizedName ( NLMISC : : CSheetId id )
{
return getSpecialWord ( id . toString ( ) ) ;
}
// ***************************************************************************
const uc char * CStringManagerClient : : getOutpostLocalizedDescription ( NLMISC : : CSheetId id )
const char * CStringManagerClient : : getOutpostLocalizedDescription ( NLMISC : : CSheetId id )
{
return getSpecialDesc ( id . toString ( ) ) ;
}
// ***************************************************************************
const uc char * CStringManagerClient : : getOutpostBuildingLocalizedName ( NLMISC : : CSheetId id )
const char * CStringManagerClient : : getOutpostBuildingLocalizedName ( NLMISC : : CSheetId id )
{
return getSpecialWord ( id . toString ( ) ) ;
}
// ***************************************************************************
const uc char * CStringManagerClient : : getOutpostBuildingLocalizedDescription ( NLMISC : : CSheetId id )
const char * CStringManagerClient : : getOutpostBuildingLocalizedDescription ( NLMISC : : CSheetId id )
{
return getSpecialDesc ( id . toString ( ) ) ;
}
// ***************************************************************************
const uc char * CStringManagerClient : : getSquadLocalizedName ( NLMISC : : CSheetId id )
const char * CStringManagerClient : : getSquadLocalizedName ( NLMISC : : CSheetId id )
{
return getSpecialWord ( id . toString ( ) ) ;
}
// ***************************************************************************
const uc char * CStringManagerClient : : getSquadLocalizedDescription ( NLMISC : : CSheetId id )
const char * CStringManagerClient : : getSquadLocalizedDescription ( NLMISC : : CSheetId id )
{
return getSpecialDesc ( id . toString ( ) ) ;
}
// ***************************************************************************
void CStringManagerClient : : replaceDynString ( const ucstring & name , const uc string & text )
void CStringManagerClient : : replaceDynString ( const std: : string & name , const std : : string & text )
{
_DynStrings [ name ] = text ;
}
// ***************************************************************************
void CStringManagerClient : : replaceSBrickName ( NLMISC : : CSheetId id , const ucstring & name , const ucstring & desc , const uc string & desc2 )
void CStringManagerClient : : replaceSBrickName ( NLMISC : : CSheetId id , const std: : string & name , const std : : string & desc , const std : : string & desc2 )
{
st d: : st ring label = id . toString ( ) ;
st ring label = id . toString ( ) ;
if ( label . empty ( ) )
{
return ;
}
// avoid case problems
static st d: : string lwrLabel ;
static st ring lwrLabel ;
lwrLabel = toLower ( label ) ;
nlassert ( ! _SpecItem_MemoryCompressed ) ; // Not allowed, strings are released!
if ( _SpecItem_MemoryCompressed )
{
ucchar * strName = ( ucchar * ) name . c_str ( ) ;
ucchar * strDesc = ( ucchar * ) desc . c_str ( ) ;
ucchar * strDesc2 = ( ucchar * ) desc2 . c_str ( ) ;
#if 0
const char * strName = name . c_str ( ) ;
const char * strDesc = desc . c_str ( ) ;
const char * strDesc2 = desc2 . c_str ( ) ;
CItemLight tmp ;
tmp . Label = ( char * ) lwrLabel . c_str ( ) ;
tmp . Label = lwrLabel . c_str ( ) ;
vector < CItemLight > : : iterator it = lower_bound ( _SpecItems . begin ( ) , _SpecItems . end ( ) , tmp , CItemLightComp ( ) ) ;
if ( it ! = _SpecItems . end ( ) )
@ -1746,6 +1749,7 @@ void CStringManagerClient::replaceSBrickName(NLMISC::CSheetId id, const ucstring
tmp . Desc2 = strDesc2 ;
_SpecItems . push_back ( tmp ) ;
}
# endif
}
else
{