|
|
@ -39,17 +39,17 @@ namespace STRING_MANAGER
|
|
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
|
|
|
map<string, CStringManagerClient::CItem> CStringManagerClient::_SpecItem_TempMap;
|
|
|
|
map<string, CStringManagerClient::CItem> CStringManagerClient::_SpecItem_TempMap;
|
|
|
|
map<ucstring, ucstring> CStringManagerClient::_DynStrings;
|
|
|
|
map<string, string> CStringManagerClient::_DynStrings;
|
|
|
|
vector<ucstring> CStringManagerClient::_TitleWords;
|
|
|
|
vector<string> CStringManagerClient::_TitleWords;
|
|
|
|
bool CStringManagerClient::_SpecItem_MemoryCompressed = false;
|
|
|
|
bool CStringManagerClient::_SpecItem_MemoryCompressed = false;
|
|
|
|
char *CStringManagerClient::_SpecItem_Labels = NULL;
|
|
|
|
char *CStringManagerClient::_SpecItem_Labels = NULL;
|
|
|
|
ucchar *CStringManagerClient::_SpecItem_NameDesc = NULL;
|
|
|
|
char *CStringManagerClient::_SpecItem_NameDesc = NULL;
|
|
|
|
vector<CStringManagerClient::CItemLight> CStringManagerClient::_SpecItems;
|
|
|
|
vector<CStringManagerClient::CItemLight> CStringManagerClient::_SpecItems;
|
|
|
|
bool MustReleaseStaticArrays = true;
|
|
|
|
bool MustReleaseStaticArrays = true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CStringManagerClient *CStringManagerClient::_Instance= NULL;
|
|
|
|
CStringManagerClient *CStringManagerClient::_Instance= NULL;
|
|
|
|
ucstring CStringManagerClient::_WaitString("???");
|
|
|
|
string CStringManagerClient::_WaitString("???");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CStringManagerClient::CStringManagerClient()
|
|
|
|
CStringManagerClient::CStringManagerClient()
|
|
|
@ -57,7 +57,7 @@ namespace STRING_MANAGER
|
|
|
|
_CacheInited = false;
|
|
|
|
_CacheInited = false;
|
|
|
|
_CacheLoaded = false;
|
|
|
|
_CacheLoaded = false;
|
|
|
|
// insert the empty string.
|
|
|
|
// insert the empty string.
|
|
|
|
_ReceivedStrings.insert(make_pair((uint)EmptyStringId, ucstring()));
|
|
|
|
_ReceivedStrings.insert(make_pair((uint)EmptyStringId, string()));
|
|
|
|
// reserve some place to avoid reallocation as possible
|
|
|
|
// reserve some place to avoid reallocation as possible
|
|
|
|
_CacheStringToSave.reserve(1024);
|
|
|
|
_CacheStringToSave.reserve(1024);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -122,6 +122,7 @@ namespace STRING_MANAGER
|
|
|
|
{
|
|
|
|
{
|
|
|
|
try
|
|
|
|
try
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
const uint currentVersion = 1;
|
|
|
|
_CacheFilename = std::string("save/") + _ShardId.substr(0, _ShardId.find(":")) + ".string_cache";
|
|
|
|
_CacheFilename = std::string("save/") + _ShardId.substr(0, _ShardId.find(":")) + ".string_cache";
|
|
|
|
|
|
|
|
|
|
|
|
nlinfo("SM : Try to open the string cache : %s", _CacheFilename.c_str());
|
|
|
|
nlinfo("SM : Try to open the string cache : %s", _CacheFilename.c_str());
|
|
|
@ -131,6 +132,8 @@ namespace STRING_MANAGER
|
|
|
|
// there is a cache file, check date reset it if needed
|
|
|
|
// there is a cache file, check date reset it if needed
|
|
|
|
{
|
|
|
|
{
|
|
|
|
NLMISC::CIFile file(_CacheFilename);
|
|
|
|
NLMISC::CIFile file(_CacheFilename);
|
|
|
|
|
|
|
|
file.setVersionException(false, false);
|
|
|
|
|
|
|
|
file.serialVersion(currentVersion);
|
|
|
|
file.serial(_Timestamp);
|
|
|
|
file.serial(_Timestamp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -139,6 +142,7 @@ namespace STRING_MANAGER
|
|
|
|
nlinfo("SM: Clearing string cache : outofdate");
|
|
|
|
nlinfo("SM: Clearing string cache : outofdate");
|
|
|
|
// the cache is not sync, reset it
|
|
|
|
// the cache is not sync, reset it
|
|
|
|
NLMISC::COFile file(_CacheFilename);
|
|
|
|
NLMISC::COFile file(_CacheFilename);
|
|
|
|
|
|
|
|
file.serialVersion(currentVersion);
|
|
|
|
file.serial(timestamp);
|
|
|
|
file.serial(timestamp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
@ -151,6 +155,7 @@ namespace STRING_MANAGER
|
|
|
|
nlinfo("SM: Creating string cache");
|
|
|
|
nlinfo("SM: Creating string cache");
|
|
|
|
// cache file don't exist, create it with the timestamp
|
|
|
|
// cache file don't exist, create it with the timestamp
|
|
|
|
NLMISC::COFile file(_CacheFilename);
|
|
|
|
NLMISC::COFile file(_CacheFilename);
|
|
|
|
|
|
|
|
file.serialVersion(currentVersion);
|
|
|
|
file.serial(timestamp);
|
|
|
|
file.serial(timestamp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -160,17 +165,19 @@ namespace STRING_MANAGER
|
|
|
|
// NB : we keep the waiting strings and dyn strings
|
|
|
|
// NB : we keep the waiting strings and dyn strings
|
|
|
|
|
|
|
|
|
|
|
|
// insert the empty string.
|
|
|
|
// insert the empty string.
|
|
|
|
_ReceivedStrings.insert(make_pair((uint)EmptyStringId, ucstring()));
|
|
|
|
_ReceivedStrings.insert(make_pair((uint)EmptyStringId, string()));
|
|
|
|
|
|
|
|
|
|
|
|
// load the cache file
|
|
|
|
// load the cache file
|
|
|
|
NLMISC::CIFile file(_CacheFilename);
|
|
|
|
NLMISC::CIFile file(_CacheFilename);
|
|
|
|
|
|
|
|
int version = file.serialVersion(currentVersion);
|
|
|
|
file.serial(_Timestamp);
|
|
|
|
file.serial(_Timestamp);
|
|
|
|
nlassert(_Timestamp == timestamp);
|
|
|
|
nlassert(_Timestamp == timestamp);
|
|
|
|
|
|
|
|
nlassert(version >= 1); // Initial version
|
|
|
|
|
|
|
|
|
|
|
|
while (!file.eof())
|
|
|
|
while (!file.eof())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
uint32 id;
|
|
|
|
uint32 id;
|
|
|
|
ucstring str;
|
|
|
|
string str;
|
|
|
|
|
|
|
|
|
|
|
|
file.serial(id);
|
|
|
|
file.serial(id);
|
|
|
|
file.serial(str);
|
|
|
|
file.serial(str);
|
|
|
@ -194,12 +201,12 @@ namespace STRING_MANAGER
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CStringManagerClient::waitString(uint32 stringId, const IStringWaiterRemover *premover, ucstring *result)
|
|
|
|
void CStringManagerClient::waitString(uint32 stringId, const IStringWaiterRemover *premover, string *result)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
H_AUTO( CStringManagerClient_waitString )
|
|
|
|
H_AUTO( CStringManagerClient_waitString )
|
|
|
|
|
|
|
|
|
|
|
|
nlassert(premover && result);
|
|
|
|
nlassert(premover && result);
|
|
|
|
ucstring value;
|
|
|
|
string value;
|
|
|
|
if (getString(stringId, value))
|
|
|
|
if (getString(stringId, value))
|
|
|
|
*result = value;
|
|
|
|
*result = value;
|
|
|
|
else
|
|
|
|
else
|
|
|
@ -217,7 +224,7 @@ namespace STRING_MANAGER
|
|
|
|
H_AUTO( CStringManagerClient_waitString2 )
|
|
|
|
H_AUTO( CStringManagerClient_waitString2 )
|
|
|
|
|
|
|
|
|
|
|
|
nlassert(pcallback != 0);
|
|
|
|
nlassert(pcallback != 0);
|
|
|
|
ucstring value;
|
|
|
|
string value;
|
|
|
|
if (getString(stringId, value))
|
|
|
|
if (getString(stringId, value))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
pcallback->onStringAvailable(stringId, value);
|
|
|
|
pcallback->onStringAvailable(stringId, value);
|
|
|
@ -230,12 +237,12 @@ namespace STRING_MANAGER
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CStringManagerClient::waitDynString(uint32 stringId, const IStringWaiterRemover *premover, ucstring *result)
|
|
|
|
void CStringManagerClient::waitDynString(uint32 stringId, const IStringWaiterRemover *premover, string *result)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
H_AUTO( CStringManagerClient_waitDynString )
|
|
|
|
H_AUTO( CStringManagerClient_waitDynString )
|
|
|
|
|
|
|
|
|
|
|
|
nlassert(premover && result);
|
|
|
|
nlassert(premover && result);
|
|
|
|
ucstring value;
|
|
|
|
string value;
|
|
|
|
if (getDynString(stringId, value))
|
|
|
|
if (getDynString(stringId, value))
|
|
|
|
*result = value;
|
|
|
|
*result = value;
|
|
|
|
else
|
|
|
|
else
|
|
|
@ -253,7 +260,7 @@ namespace STRING_MANAGER
|
|
|
|
H_AUTO( CStringManagerClient_waitDynString2 )
|
|
|
|
H_AUTO( CStringManagerClient_waitDynString2 )
|
|
|
|
|
|
|
|
|
|
|
|
nlassert(pcallback != 0);
|
|
|
|
nlassert(pcallback != 0);
|
|
|
|
ucstring value;
|
|
|
|
string value;
|
|
|
|
if (getDynString(stringId, value))
|
|
|
|
if (getDynString(stringId, value))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
pcallback->onDynStringAvailable(stringId, value);
|
|
|
|
pcallback->onDynStringAvailable(stringId, value);
|
|
|
@ -330,7 +337,7 @@ restartLoop4:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool CStringManagerClient::getString(uint32 stringId, ucstring &result)
|
|
|
|
bool CStringManagerClient::getString(uint32 stringId, string &result)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
H_AUTO( CStringManagerClient_getString )
|
|
|
|
H_AUTO( CStringManagerClient_getString )
|
|
|
|
|
|
|
|
|
|
|
@ -357,7 +364,7 @@ restartLoop4:
|
|
|
|
_WaitingStrings.insert(stringId);
|
|
|
|
_WaitingStrings.insert(stringId);
|
|
|
|
// need to ask for this string.
|
|
|
|
// need to ask for this string.
|
|
|
|
NLMISC::CBitMemStream bms;
|
|
|
|
NLMISC::CBitMemStream bms;
|
|
|
|
const std::string msgType = "STRING_MANAGER:STRING_RQ";
|
|
|
|
const string msgType = "STRING_MANAGER:STRING_RQ";
|
|
|
|
if( GenericMsgHeaderMngr.pushNameToStream(msgType,bms) )
|
|
|
|
if( GenericMsgHeaderMngr.pushNameToStream(msgType,bms) )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
bms.serial( stringId );
|
|
|
|
bms.serial( stringId );
|
|
|
@ -374,7 +381,7 @@ restartLoop4:
|
|
|
|
{
|
|
|
|
{
|
|
|
|
char tmp[1024];
|
|
|
|
char tmp[1024];
|
|
|
|
sprintf(tmp, "<WAIT STR %u>", stringId);
|
|
|
|
sprintf(tmp, "<WAIT STR %u>", stringId);
|
|
|
|
result = ucstring(tmp);
|
|
|
|
result = tmp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
result.erase(); // = _WaitString;
|
|
|
|
result.erase(); // = _WaitString;
|
|
|
@ -385,14 +392,14 @@ restartLoop4:
|
|
|
|
{
|
|
|
|
{
|
|
|
|
char tmp[1024];
|
|
|
|
char tmp[1024];
|
|
|
|
sprintf(tmp, "<STR %u>", stringId);
|
|
|
|
sprintf(tmp, "<STR %u>", stringId);
|
|
|
|
result = ucstring(tmp) + it->second;
|
|
|
|
result = tmp + it->second;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
result = it->second;
|
|
|
|
result = it->second;
|
|
|
|
if (result.size() > 9 && result.substr(0, 9) == ucstring("<missing:"))
|
|
|
|
if (result.size() > 9 && result.substr(0, 9) == "<missing:")
|
|
|
|
{
|
|
|
|
{
|
|
|
|
map<ucstring, ucstring>::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())
|
|
|
|
if (itds != _DynStrings.end())
|
|
|
|
result = itds->second;
|
|
|
|
result = itds->second;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -402,7 +409,7 @@ restartLoop4:
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CStringManagerClient::receiveString(uint32 stringId, const ucstring &str)
|
|
|
|
void CStringManagerClient::receiveString(uint32 stringId, const string &str)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
H_AUTO( CStringManagerClient_receiveString )
|
|
|
|
H_AUTO( CStringManagerClient_receiveString )
|
|
|
|
|
|
|
|
|
|
|
@ -419,8 +426,8 @@ restartLoop4:
|
|
|
|
TStringsContainer::iterator it(_ReceivedStrings.find(stringId));
|
|
|
|
TStringsContainer::iterator it(_ReceivedStrings.find(stringId));
|
|
|
|
nlwarning("Receiving stringID %u (%s), already in received string (%s), replacing with new value.",
|
|
|
|
nlwarning("Receiving stringID %u (%s), already in received string (%s), replacing with new value.",
|
|
|
|
stringId,
|
|
|
|
stringId,
|
|
|
|
str.toString().c_str(),
|
|
|
|
str.c_str(),
|
|
|
|
it->second.toString().c_str());
|
|
|
|
it->second.c_str());
|
|
|
|
|
|
|
|
|
|
|
|
if (it->second != str)
|
|
|
|
if (it->second != str)
|
|
|
|
it->second = str;
|
|
|
|
it->second = str;
|
|
|
@ -484,7 +491,7 @@ restartLoop:
|
|
|
|
last = _WaitingDynStrings.end();
|
|
|
|
last = _WaitingDynStrings.end();
|
|
|
|
for (; first != last; ++first)
|
|
|
|
for (; first != last; ++first)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ucstring value;
|
|
|
|
string value;
|
|
|
|
uint number = first->first;
|
|
|
|
uint number = first->first;
|
|
|
|
/// Warning: if getDynString() return true, 'first' is erased => don't use it after in this loop
|
|
|
|
/// Warning: if getDynString() return true, 'first' is erased => don't use it after in this loop
|
|
|
|
if (getDynString(number, value))
|
|
|
|
if (getDynString(number, value))
|
|
|
@ -616,7 +623,7 @@ restartLoop:
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// ok, we have the base string, we can serial the parameters
|
|
|
|
// ok, we have the base string, we can serial the parameters
|
|
|
|
ucstring::iterator first(dynInfo.String.begin()), last(dynInfo.String.end());
|
|
|
|
string::iterator first(dynInfo.String.begin()), last(dynInfo.String.end());
|
|
|
|
for (; first != last; ++first)
|
|
|
|
for (; first != last; ++first)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (*first == '%')
|
|
|
|
if (*first == '%')
|
|
|
@ -699,10 +706,10 @@ restartLoop:
|
|
|
|
if (dynInfo.Status == TDynStringInfo::serialized)
|
|
|
|
if (dynInfo.Status == TDynStringInfo::serialized)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// try to retreive all string parameter to build the string.
|
|
|
|
// try to retreive all string parameter to build the string.
|
|
|
|
ucstring temp;
|
|
|
|
string temp;
|
|
|
|
temp.reserve(dynInfo.String.size() * 2);
|
|
|
|
temp.reserve(dynInfo.String.size() * 2);
|
|
|
|
ucstring::iterator src(dynInfo.String.begin());
|
|
|
|
string::iterator src(dynInfo.String.begin());
|
|
|
|
ucstring::iterator move = src;
|
|
|
|
string::iterator move = src;
|
|
|
|
|
|
|
|
|
|
|
|
std::vector<TParamValue>::iterator first(dynInfo.Params.begin()), last(dynInfo.Params.end());
|
|
|
|
std::vector<TParamValue>::iterator first(dynInfo.Params.begin()), last(dynInfo.Params.end());
|
|
|
|
for (; first != last; ++first)
|
|
|
|
for (; first != last; ++first)
|
|
|
@ -712,7 +719,7 @@ restartLoop:
|
|
|
|
{
|
|
|
|
{
|
|
|
|
case string_id:
|
|
|
|
case string_id:
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ucstring str;
|
|
|
|
string str;
|
|
|
|
if (!getString(param.StringId, str))
|
|
|
|
if (!getString(param.StringId, str))
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
@ -741,10 +748,10 @@ restartLoop:
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// If the string contains a title, then remove it
|
|
|
|
// If the string contains a title, then remove it
|
|
|
|
ucstring::size_type pos = str.find('$');
|
|
|
|
string::size_type pos = str.find('$');
|
|
|
|
if ( ! str.empty() && pos != ucstring::npos)
|
|
|
|
if ( ! str.empty() && pos != ucstring::npos)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
str = CEntityCL::removeTitleFromName(str.toUtf8());
|
|
|
|
str = CEntityCL::removeTitleFromName(str);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// append this string
|
|
|
|
// append this string
|
|
|
@ -759,13 +766,13 @@ restartLoop:
|
|
|
|
char value[1024];
|
|
|
|
char value[1024];
|
|
|
|
sprintf(value, "%d", param.Integer);
|
|
|
|
sprintf(value, "%d", param.Integer);
|
|
|
|
temp.append(move, src+param.ReplacementPoint);
|
|
|
|
temp.append(move, src+param.ReplacementPoint);
|
|
|
|
temp+=ucstring(value);
|
|
|
|
temp += value;
|
|
|
|
move = dynInfo.String.begin()+param.ReplacementPoint+2;
|
|
|
|
move = dynInfo.String.begin()+param.ReplacementPoint+2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case time:
|
|
|
|
case time:
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ucstring value;
|
|
|
|
string value;
|
|
|
|
uint32 time = (uint32)param.Time;
|
|
|
|
uint32 time = (uint32)param.Time;
|
|
|
|
if( time >= (10*60*60) )
|
|
|
|
if( time >= (10*60*60) )
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -796,7 +803,7 @@ restartLoop:
|
|
|
|
char value[1024];
|
|
|
|
char value[1024];
|
|
|
|
sprintf(value, "%u", (uint32)param.Money);
|
|
|
|
sprintf(value, "%u", (uint32)param.Money);
|
|
|
|
temp.append(move, src+param.ReplacementPoint);
|
|
|
|
temp.append(move, src+param.ReplacementPoint);
|
|
|
|
temp+=ucstring(value);
|
|
|
|
temp += value;
|
|
|
|
move = dynInfo.String.begin()+param.ReplacementPoint+2;
|
|
|
|
move = dynInfo.String.begin()+param.ReplacementPoint+2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// TODO
|
|
|
|
// TODO
|
|
|
@ -805,7 +812,7 @@ restartLoop:
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case dyn_string_id:
|
|
|
|
case dyn_string_id:
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ucstring dynStr;
|
|
|
|
string dynStr;
|
|
|
|
if (!getDynString(param.DynStringId, dynStr))
|
|
|
|
if (!getDynString(param.DynStringId, dynStr))
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
temp.append(move, src+param.ReplacementPoint);
|
|
|
|
temp.append(move, src+param.ReplacementPoint);
|
|
|
@ -823,8 +830,8 @@ restartLoop:
|
|
|
|
|
|
|
|
|
|
|
|
// apply any 'delete' character in the string and replace double '%'
|
|
|
|
// apply any 'delete' character in the string and replace double '%'
|
|
|
|
{
|
|
|
|
{
|
|
|
|
uint i =0;
|
|
|
|
ptrdiff_t i =0;
|
|
|
|
while (i < temp.size())
|
|
|
|
while (i < (ptrdiff_t)temp.size())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (temp[i] == 8)
|
|
|
|
if (temp[i] == 8)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -853,7 +860,7 @@ restartLoop:
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool CStringManagerClient::getDynString(uint32 dynStringId, ucstring &result)
|
|
|
|
bool CStringManagerClient::getDynString(uint32 dynStringId, std::string &result)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
H_AUTO( CStringManagerClient_getDynString )
|
|
|
|
H_AUTO( CStringManagerClient_getDynString )
|
|
|
|
|
|
|
|
|
|
|
@ -882,7 +889,7 @@ restartLoop:
|
|
|
|
{
|
|
|
|
{
|
|
|
|
char tmp[1024];
|
|
|
|
char tmp[1024];
|
|
|
|
sprintf(tmp, "<DYNSTR %u>", dynStringId);
|
|
|
|
sprintf(tmp, "<DYNSTR %u>", dynStringId);
|
|
|
|
result = ucstring(tmp) + it->second.String;
|
|
|
|
result = tmp + it->second.String;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
result = it->second.String;
|
|
|
|
result = it->second.String;
|
|
|
@ -908,7 +915,7 @@ restartLoop:
|
|
|
|
nlwarning("DynStringID %u is unknown !", dynStringId);
|
|
|
|
nlwarning("DynStringID %u is unknown !", dynStringId);
|
|
|
|
char tmp[1024];
|
|
|
|
char tmp[1024];
|
|
|
|
sprintf(tmp, "<UNKNOWN DYNSTR %u>", dynStringId);
|
|
|
|
sprintf(tmp, "<UNKNOWN DYNSTR %u>", dynStringId);
|
|
|
|
result = ucstring(tmp);
|
|
|
|
result = tmp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
result.erase(); //_WaitString;
|
|
|
|
result.erase(); //_WaitString;
|
|
|
@ -920,7 +927,7 @@ restartLoop:
|
|
|
|
{
|
|
|
|
{
|
|
|
|
char tmp[1024];
|
|
|
|
char tmp[1024];
|
|
|
|
sprintf(tmp, "<DYNSTR %u>", dynStringId);
|
|
|
|
sprintf(tmp, "<DYNSTR %u>", dynStringId);
|
|
|
|
result = ucstring(tmp) + it->second.String;
|
|
|
|
result = tmp + it->second.String;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
result = it->second.String;
|
|
|
|
result = it->second.String;
|
|
|
@ -933,7 +940,7 @@ restartLoop:
|
|
|
|
{
|
|
|
|
{
|
|
|
|
char tmp[1024];
|
|
|
|
char tmp[1024];
|
|
|
|
sprintf(tmp, "<WAIT DYNSTR %u>", dynStringId);
|
|
|
|
sprintf(tmp, "<WAIT DYNSTR %u>", dynStringId);
|
|
|
|
result = ucstring(tmp);
|
|
|
|
result = tmp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
result.erase(); // = _WaitString;
|
|
|
|
result.erase(); // = _WaitString;
|
|
|
@ -943,7 +950,7 @@ restartLoop:
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Tool fct to lookup a reference file
|
|
|
|
// Tool fct to lookup a reference file
|
|
|
|
static string lookupReferenceFile(const std::string &fileName)
|
|
|
|
static string lookupReferenceFile(const string &fileName)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
string referenceFile;
|
|
|
|
string referenceFile;
|
|
|
|
// special location for the "wk" language
|
|
|
|
// special location for the "wk" language
|
|
|
@ -964,14 +971,14 @@ restartLoop:
|
|
|
|
return referenceFile;
|
|
|
|
return referenceFile;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CLoadProxy::loadStringFile(const std::string &filename, ucstring &text)
|
|
|
|
void CLoadProxy::loadStringFile(const string &filename, ucstring &text)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
vector<TStringInfo> reference;
|
|
|
|
vector<TStringInfo> reference;
|
|
|
|
vector<TStringInfo> addition;
|
|
|
|
vector<TStringInfo> addition;
|
|
|
|
vector<TStringInfo> diff;
|
|
|
|
vector<TStringInfo> diff;
|
|
|
|
|
|
|
|
|
|
|
|
// get the correct path name of the ref file
|
|
|
|
// get the correct path name of the ref file
|
|
|
|
std::string referenceFile= lookupReferenceFile(filename);
|
|
|
|
string referenceFile= lookupReferenceFile(filename);
|
|
|
|
|
|
|
|
|
|
|
|
// load the reference file
|
|
|
|
// load the reference file
|
|
|
|
if (!referenceFile.empty())
|
|
|
|
if (!referenceFile.empty())
|
|
|
@ -1041,7 +1048,7 @@ public:
|
|
|
|
TWorksheet diff;
|
|
|
|
TWorksheet diff;
|
|
|
|
|
|
|
|
|
|
|
|
// get the correct path name of the ref file
|
|
|
|
// get the correct path name of the ref file
|
|
|
|
std::string referenceFile= lookupReferenceFile(filename);
|
|
|
|
string referenceFile= lookupReferenceFile(filename);
|
|
|
|
|
|
|
|
|
|
|
|
// load the reference file
|
|
|
|
// load the reference file
|
|
|
|
if (!referenceFile.empty())
|
|
|
|
if (!referenceFile.empty())
|
|
|
@ -1134,7 +1141,7 @@ public:
|
|
|
|
const string StringClientPackedFileName= "./save/string_client.pack";
|
|
|
|
const string StringClientPackedFileName= "./save/string_client.pack";
|
|
|
|
// Must Increment this number if change are made to the code (else change not taken into account)
|
|
|
|
// Must Increment this number if change are made to the code (else change not taken into account)
|
|
|
|
const uint StringClientPackedVersion= 0;
|
|
|
|
const uint StringClientPackedVersion= 0;
|
|
|
|
bool CStringManagerClient::checkWordFileDates(vector<CFileCheck> &fileChecks, const std::vector<std::string> &fileNames, const std::string &languageCode)
|
|
|
|
bool CStringManagerClient::checkWordFileDates(vector<CFileCheck> &fileChecks, const std::vector<string> &fileNames, const string &languageCode)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
fileChecks.resize(fileNames.size());
|
|
|
|
fileChecks.resize(fileNames.size());
|
|
|
|
|
|
|
|
|
|
|
@ -1142,7 +1149,7 @@ bool CStringManagerClient::checkWordFileDates(vector<CFileCheck> &fileChecks, co
|
|
|
|
for(uint i=0;i<fileChecks.size();i++)
|
|
|
|
for(uint i=0;i<fileChecks.size();i++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// get the correct path name of the ref file
|
|
|
|
// get the correct path name of the ref file
|
|
|
|
std::string referenceFile= lookupReferenceFile(fileNames[i]);
|
|
|
|
string referenceFile= lookupReferenceFile(fileNames[i]);
|
|
|
|
fileChecks[i].ReferenceDate= referenceFile.empty()?0:CFile::getFileModificationDate(referenceFile);
|
|
|
|
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)
|
|
|
|
// get then one of the working File (NB: 0 is a valid reponse for Final Client: no working file)
|
|
|
@ -1169,7 +1176,7 @@ bool CStringManagerClient::checkWordFileDates(vector<CFileCheck> &fileChecks, co
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
|
|
|
void CStringManagerClient::initI18NSpecialWords(const std::string &languageCode)
|
|
|
|
void CStringManagerClient::initI18NSpecialWords(const string &languageCode)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ucstring womenNameColIdent= string("women_name");
|
|
|
|
ucstring womenNameColIdent= string("women_name");
|
|
|
|
ucstring descColIdent= string("description");
|
|
|
|
ucstring descColIdent= string("description");
|
|
|
@ -1213,8 +1220,8 @@ void CStringManagerClient::initI18NSpecialWords(const std::string &languageCode)
|
|
|
|
uint32 profile0= (uint32)ryzomGetLocalTime();
|
|
|
|
uint32 profile0= (uint32)ryzomGetLocalTime();
|
|
|
|
|
|
|
|
|
|
|
|
ucstring ucs;
|
|
|
|
ucstring ucs;
|
|
|
|
std::string fileName = fileNames[i];
|
|
|
|
string fileName = fileNames[i];
|
|
|
|
std::string keyExtenstion = specialWords[i*3+2];
|
|
|
|
string keyExtenstion = specialWords[i*3+2];
|
|
|
|
|
|
|
|
|
|
|
|
// read the ucstring and make diffs with data in ./translation/work.
|
|
|
|
// read the ucstring and make diffs with data in ./translation/work.
|
|
|
|
CReadWorkSheetFile rwsf;
|
|
|
|
CReadWorkSheetFile rwsf;
|
|
|
@ -1250,17 +1257,17 @@ void CStringManagerClient::initI18NSpecialWords(const std::string &languageCode)
|
|
|
|
for(uint j=1;j<ws.size();j++)
|
|
|
|
for(uint j=1;j<ws.size();j++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Get the key and name string.
|
|
|
|
// Get the key and name string.
|
|
|
|
const ucstring &key= ws.getData(j, keyColIndex);
|
|
|
|
const string &key= ws.getData(j, keyColIndex).toUtf8();
|
|
|
|
const ucstring &name= ws.getData(j, nameColIndex);
|
|
|
|
const string &name= ws.getData(j, nameColIndex).toUtf8();
|
|
|
|
// Append to the I18N.
|
|
|
|
// Append to the I18N.
|
|
|
|
// avoid case problems
|
|
|
|
// avoid case problems
|
|
|
|
string keyStr= NLMISC::toLower(key.toString());
|
|
|
|
string keyStr = NLMISC::toLower(key);
|
|
|
|
|
|
|
|
|
|
|
|
// append the special key extension.
|
|
|
|
// append the special key extension.
|
|
|
|
keyStr+= keyExtenstion;
|
|
|
|
keyStr+= keyExtenstion;
|
|
|
|
|
|
|
|
|
|
|
|
// insert in map.
|
|
|
|
// insert in map.
|
|
|
|
std::map<std::string, CItem>::iterator it;
|
|
|
|
std::map<string, CItem>::iterator it;
|
|
|
|
it= _SpecItem_TempMap.find( keyStr );
|
|
|
|
it= _SpecItem_TempMap.find( keyStr );
|
|
|
|
if ( it!=_SpecItem_TempMap.end() )
|
|
|
|
if ( it!=_SpecItem_TempMap.end() )
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -1276,7 +1283,7 @@ void CStringManagerClient::initI18NSpecialWords(const std::string &languageCode)
|
|
|
|
if(womenNameColIndex!=std::numeric_limits<uint>::max())
|
|
|
|
if(womenNameColIndex!=std::numeric_limits<uint>::max())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
const ucstring &womenName= ws.getData(j, womenNameColIndex);
|
|
|
|
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
|
|
|
|
// replace all \n in the women name with true \n
|
|
|
|
while(strFindReplace(_SpecItem_TempMap[keyStr].WomenName, "\\n", "\n"));
|
|
|
|
while(strFindReplace(_SpecItem_TempMap[keyStr].WomenName, "\\n", "\n"));
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1285,7 +1292,7 @@ void CStringManagerClient::initI18NSpecialWords(const std::string &languageCode)
|
|
|
|
if(descColIndex!=std::numeric_limits<uint>::max())
|
|
|
|
if(descColIndex!=std::numeric_limits<uint>::max())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
const ucstring &desc= ws.getData(j, descColIndex);
|
|
|
|
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
|
|
|
|
// replace all \n in the desc with true \n
|
|
|
|
while(strFindReplace(_SpecItem_TempMap[keyStr].Desc, "\\n", "\n"));
|
|
|
|
while(strFindReplace(_SpecItem_TempMap[keyStr].Desc, "\\n", "\n"));
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1294,7 +1301,7 @@ void CStringManagerClient::initI18NSpecialWords(const std::string &languageCode)
|
|
|
|
if(descColIndex2!=std::numeric_limits<uint>::max())
|
|
|
|
if(descColIndex2!=std::numeric_limits<uint>::max())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
const ucstring &desc= ws.getData(j, descColIndex2);
|
|
|
|
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
|
|
|
|
// replace all \n in the desc with true \n
|
|
|
|
while(strFindReplace(_SpecItem_TempMap[keyStr].Desc2, "\\n", "\n"));
|
|
|
|
while(strFindReplace(_SpecItem_TempMap[keyStr].Desc2, "\\n", "\n"));
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1358,7 +1365,7 @@ void CStringManagerClient::specialWordsMemoryCompress()
|
|
|
|
// Make big strings
|
|
|
|
// Make big strings
|
|
|
|
_SpecItems.resize(nNbEntries);
|
|
|
|
_SpecItems.resize(nNbEntries);
|
|
|
|
_SpecItem_Labels = new char[nLabelSize];
|
|
|
|
_SpecItem_Labels = new char[nLabelSize];
|
|
|
|
_SpecItem_NameDesc = new ucchar[nNameDescSize];
|
|
|
|
_SpecItem_NameDesc = new char[nNameDescSize];
|
|
|
|
|
|
|
|
|
|
|
|
nNbEntries = 0;
|
|
|
|
nNbEntries = 0;
|
|
|
|
nLabelSize = 0;
|
|
|
|
nLabelSize = 0;
|
|
|
@ -1366,35 +1373,30 @@ void CStringManagerClient::specialWordsMemoryCompress()
|
|
|
|
it = _SpecItem_TempMap.begin();
|
|
|
|
it = _SpecItem_TempMap.begin();
|
|
|
|
while (it != _SpecItem_TempMap.end())
|
|
|
|
while (it != _SpecItem_TempMap.end())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
if (NLMISC::startsWith(it->first.c_str(), "bf"))
|
|
|
|
if (strnicmp(it->first.c_str(), "bf", 2) == 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
uint nDbg = 0;
|
|
|
|
uint nDbg = 0;
|
|
|
|
nDbg++;
|
|
|
|
nDbg++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
_SpecItems[nNbEntries].Label = _SpecItem_Labels+nLabelSize;
|
|
|
|
_SpecItems[nNbEntries].Label = _SpecItem_Labels+nLabelSize;
|
|
|
|
strcpy(_SpecItems[nNbEntries].Label, it->first.c_str());
|
|
|
|
strcpy(_SpecItem_Labels+nLabelSize, it->first.c_str());
|
|
|
|
nLabelSize += (uint32)it->first.size() + 1;
|
|
|
|
nLabelSize += (uint32)it->first.size() + 1;
|
|
|
|
|
|
|
|
|
|
|
|
_SpecItems[nNbEntries].Name = _SpecItem_NameDesc+nNameDescSize;
|
|
|
|
_SpecItems[nNbEntries].Name = _SpecItem_NameDesc+nNameDescSize;
|
|
|
|
memcpy(_SpecItems[nNbEntries].Name, it->second.Name.c_str(), 2*(it->second.Name.size()+1));
|
|
|
|
strcpy(_SpecItem_NameDesc+nNameDescSize, it->second.Name.c_str());
|
|
|
|
_SpecItems[nNbEntries].Name[it->second.Name.size()] = 0;
|
|
|
|
|
|
|
|
nNameDescSize += (uint32)it->second.Name.size() + 1;
|
|
|
|
nNameDescSize += (uint32)it->second.Name.size() + 1;
|
|
|
|
|
|
|
|
|
|
|
|
_SpecItems[nNbEntries].WomenName = _SpecItem_NameDesc+nNameDescSize;
|
|
|
|
_SpecItems[nNbEntries].WomenName = _SpecItem_NameDesc+nNameDescSize;
|
|
|
|
memcpy(_SpecItems[nNbEntries].WomenName, it->second.WomenName.c_str(), 2*(it->second.WomenName.size()+1));
|
|
|
|
strcpy(_SpecItem_NameDesc+nNameDescSize, it->second.WomenName.c_str());
|
|
|
|
_SpecItems[nNbEntries].WomenName[it->second.WomenName.size()] = 0;
|
|
|
|
|
|
|
|
nNameDescSize += (uint32)it->second.WomenName.size() + 1;
|
|
|
|
nNameDescSize += (uint32)it->second.WomenName.size() + 1;
|
|
|
|
|
|
|
|
|
|
|
|
_SpecItems[nNbEntries].Desc = _SpecItem_NameDesc+nNameDescSize;
|
|
|
|
_SpecItems[nNbEntries].Desc = _SpecItem_NameDesc+nNameDescSize;
|
|
|
|
memcpy(_SpecItems[nNbEntries].Desc, it->second.Desc.c_str(), 2*(it->second.Desc.size()+1));
|
|
|
|
strcpy(_SpecItem_NameDesc+nNameDescSize, it->second.Desc.c_str());
|
|
|
|
_SpecItems[nNbEntries].Desc[it->second.Desc.size()] = 0;
|
|
|
|
|
|
|
|
nNameDescSize += (uint32)it->second.Desc.size() + 1;
|
|
|
|
nNameDescSize += (uint32)it->second.Desc.size() + 1;
|
|
|
|
|
|
|
|
|
|
|
|
_SpecItems[nNbEntries].Desc2 = _SpecItem_NameDesc+nNameDescSize;
|
|
|
|
_SpecItems[nNbEntries].Desc2 = _SpecItem_NameDesc+nNameDescSize;
|
|
|
|
memcpy(_SpecItems[nNbEntries].Desc2, it->second.Desc2.c_str(), 2*(it->second.Desc2.size()+1));
|
|
|
|
strcpy(_SpecItem_NameDesc+nNameDescSize, it->second.Desc2.c_str());
|
|
|
|
_SpecItems[nNbEntries].Desc2[it->second.Desc2.size()] = 0;
|
|
|
|
|
|
|
|
nNameDescSize += (uint32)it->second.Desc2.size() + 1;
|
|
|
|
nNameDescSize += (uint32)it->second.Desc2.size() + 1;
|
|
|
|
|
|
|
|
|
|
|
|
nNbEntries++;
|
|
|
|
nNbEntries++;
|
|
|
@ -1406,22 +1408,21 @@ 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())
|
|
|
|
if (label.empty())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
static ucstring emptyString;
|
|
|
|
static string emptyString;
|
|
|
|
return emptyString.c_str();
|
|
|
|
return emptyString.c_str();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (label[0] == '#')
|
|
|
|
if (label[0] == '#')
|
|
|
|
{
|
|
|
|
{
|
|
|
|
static ucstring rawString;
|
|
|
|
|
|
|
|
return getLocalizedName(label.substr(1, label.size()-1));
|
|
|
|
return getLocalizedName(label.substr(1, label.size()-1));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// avoid case problems
|
|
|
|
// avoid case problems
|
|
|
|
static std::string lwrLabel;
|
|
|
|
static string lwrLabel;
|
|
|
|
lwrLabel = toLower(label);
|
|
|
|
lwrLabel = toLower(label);
|
|
|
|
|
|
|
|
|
|
|
|
if (_SpecItem_MemoryCompressed)
|
|
|
|
if (_SpecItem_MemoryCompressed)
|
|
|
@ -1456,28 +1457,26 @@ const ucchar * CStringManagerClient::getSpecialWord(const std::string &label, bo
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static ucstring badString;
|
|
|
|
static string badString;
|
|
|
|
|
|
|
|
badString = "<NotExist:" + lwrLabel + ">";
|
|
|
|
badString = ucstring(std::string("<NotExist:")+lwrLabel+">");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return badString.c_str();
|
|
|
|
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())
|
|
|
|
if (label.empty())
|
|
|
|
return emptyString.c_str();
|
|
|
|
return emptyString.c_str();
|
|
|
|
|
|
|
|
|
|
|
|
// avoid case problems
|
|
|
|
// avoid case problems
|
|
|
|
static std::string lwrLabel;
|
|
|
|
static string lwrLabel;
|
|
|
|
lwrLabel = toLower(label);
|
|
|
|
lwrLabel = toLower(label);
|
|
|
|
|
|
|
|
|
|
|
|
if (_SpecItem_MemoryCompressed)
|
|
|
|
if (_SpecItem_MemoryCompressed)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
CItemLight tmp;
|
|
|
|
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());
|
|
|
|
vector<CItemLight>::iterator it = lower_bound(_SpecItems.begin(), _SpecItems.end(), tmp, CItemLightComp());
|
|
|
|
|
|
|
|
|
|
|
|
if (it != _SpecItems.end())
|
|
|
|
if (it != _SpecItems.end())
|
|
|
@ -1497,20 +1496,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())
|
|
|
|
if (label.empty())
|
|
|
|
return emptyString.c_str();
|
|
|
|
return emptyString.c_str();
|
|
|
|
|
|
|
|
|
|
|
|
// avoid case problems
|
|
|
|
// avoid case problems
|
|
|
|
static std::string lwrLabel;
|
|
|
|
static string lwrLabel;
|
|
|
|
lwrLabel = toLower(label);
|
|
|
|
lwrLabel = toLower(label);
|
|
|
|
|
|
|
|
|
|
|
|
if (_SpecItem_MemoryCompressed)
|
|
|
|
if (_SpecItem_MemoryCompressed)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
CItemLight tmp;
|
|
|
|
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());
|
|
|
|
vector<CItemLight>::iterator it = lower_bound(_SpecItems.begin(), _SpecItems.end(), tmp, CItemLightComp());
|
|
|
|
|
|
|
|
|
|
|
|
if (it != _SpecItems.end())
|
|
|
|
if (it != _SpecItems.end())
|
|
|
@ -1539,87 +1538,88 @@ const ucchar * CStringManagerClient::getSpecialDesc2(const std::string &label)
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
|
|
|
const ucchar *CStringManagerClient::getPlaceLocalizedName(const string &placeNameID)
|
|
|
|
const char *CStringManagerClient::getPlaceLocalizedName(const string &placeNameID)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return getSpecialWord(placeNameID);
|
|
|
|
return getSpecialWord(placeNameID);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
|
|
|
const ucchar *CStringManagerClient::getFactionLocalizedName(const string &factionNameID)
|
|
|
|
const char *CStringManagerClient::getFactionLocalizedName(const string &factionNameID)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return getSpecialWord(factionNameID);
|
|
|
|
return getSpecialWord(factionNameID);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
|
|
|
const ucchar *CStringManagerClient::getSkillLocalizedName(SKILLS::ESkills e)
|
|
|
|
const char *CStringManagerClient::getSkillLocalizedName(SKILLS::ESkills e)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return getSpecialWord(SKILLS::toString(e));
|
|
|
|
return getSpecialWord(SKILLS::toString(e));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
|
|
|
const ucchar *CStringManagerClient::getItemLocalizedName(CSheetId id)
|
|
|
|
const char *CStringManagerClient::getItemLocalizedName(CSheetId id)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return getSpecialWord(id.toString());
|
|
|
|
return getSpecialWord(id.toString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
|
|
|
const ucchar *CStringManagerClient::getCreatureLocalizedName(NLMISC::CSheetId id)
|
|
|
|
const char *CStringManagerClient::getCreatureLocalizedName(NLMISC::CSheetId id)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return getSpecialWord(id.toString());
|
|
|
|
return getSpecialWord(id.toString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
|
|
|
const ucchar *CStringManagerClient::getSBrickLocalizedName(NLMISC::CSheetId id)
|
|
|
|
const char *CStringManagerClient::getSBrickLocalizedName(NLMISC::CSheetId id)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return getSpecialWord(id.toString());
|
|
|
|
return getSpecialWord(id.toString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
|
|
|
const ucchar *CStringManagerClient::getSPhraseLocalizedName(NLMISC::CSheetId id)
|
|
|
|
const char *CStringManagerClient::getSPhraseLocalizedName(NLMISC::CSheetId id)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return getSpecialWord(id.toString());
|
|
|
|
return getSpecialWord(id.toString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
|
|
|
/*const ucchar *CStringManagerClient::getBrickLocalizedDescription(BRICK_FAMILIES::TBrickFamily e)
|
|
|
|
/*const char *CStringManagerClient::getBrickLocalizedDescription(BRICK_FAMILIES::TBrickFamily e)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return getSpecialDesc(BRICK_FAMILIES::toString(e));
|
|
|
|
return getSpecialDesc(BRICK_FAMILIES::toString(e));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
|
|
|
const ucchar *CStringManagerClient::getSkillLocalizedDescription(SKILLS::ESkills e)
|
|
|
|
const char *CStringManagerClient::getSkillLocalizedDescription(SKILLS::ESkills e)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return getSpecialDesc(SKILLS::toString(e));
|
|
|
|
return getSpecialDesc(SKILLS::toString(e));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
|
|
|
const ucchar *CStringManagerClient::getItemLocalizedDescription(CSheetId id)
|
|
|
|
const char *CStringManagerClient::getItemLocalizedDescription(CSheetId id)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return getSpecialDesc(id.toString());
|
|
|
|
return getSpecialDesc(id.toString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
|
|
|
const ucchar *CStringManagerClient::getSBrickLocalizedDescription(NLMISC::CSheetId id)
|
|
|
|
const char *CStringManagerClient::getSBrickLocalizedDescription(NLMISC::CSheetId id)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return getSpecialDesc(id.toString());
|
|
|
|
return getSpecialDesc(id.toString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
|
|
|
const ucchar *CStringManagerClient::getSBrickLocalizedCompositionDescription(NLMISC::CSheetId id)
|
|
|
|
const char *CStringManagerClient::getSBrickLocalizedCompositionDescription(NLMISC::CSheetId id)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return getSpecialDesc2(id.toString());
|
|
|
|
return getSpecialDesc2(id.toString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
|
|
|
const ucchar *CStringManagerClient::getSPhraseLocalizedDescription(NLMISC::CSheetId id)
|
|
|
|
const char *CStringManagerClient::getSPhraseLocalizedDescription(NLMISC::CSheetId id)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return getSpecialDesc(id.toString());
|
|
|
|
return getSpecialDesc(id.toString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
|
|
|
const ucchar *CStringManagerClient::getTitleLocalizedName(const ucstring &titleId, bool women)
|
|
|
|
const char *CStringManagerClient::getTitleLocalizedName(const string &titleId, bool women)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
vector<ucstring> listInfos = getTitleInfos(titleId, women);
|
|
|
|
vector<string> listInfos = getTitleInfos(titleId, women);
|
|
|
|
|
|
|
|
|
|
|
|
if (!listInfos.empty())
|
|
|
|
if (!listInfos.empty())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_TitleWords.push_back(listInfos[0]);
|
|
|
|
_TitleWords.push_back(listInfos[0]);
|
|
|
@ -1661,18 +1661,18 @@ const ucchar *CStringManagerClient::getLocalizedName(const ucstring &uctext)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
|
|
|
vector<ucstring> CStringManagerClient::getTitleInfos(const ucstring &titleId, bool women)
|
|
|
|
vector<string> CStringManagerClient::getTitleInfos(const string &titleId, bool women)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//ucstring infosUC;
|
|
|
|
//ucstring infosUC;
|
|
|
|
//infosUC.fromUtf8(titleId);
|
|
|
|
//infosUC.fromUtf8(titleId);
|
|
|
|
vector<ucstring> listInfos;
|
|
|
|
vector<string> listInfos;
|
|
|
|
splitUCString(titleId, ucstring("#"), listInfos);
|
|
|
|
splitString(titleId, string("#"), listInfos);
|
|
|
|
|
|
|
|
|
|
|
|
if (!listInfos.empty())
|
|
|
|
if (!listInfos.empty())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (titleId[0] != '#')
|
|
|
|
if (titleId[0] != '#')
|
|
|
|
{
|
|
|
|
{
|
|
|
|
listInfos[0] = getSpecialWord(listInfos[0].toUtf8(), women);
|
|
|
|
listInfos[0] = getSpecialWord(listInfos[0], women);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -1680,74 +1680,76 @@ vector<ucstring> CStringManagerClient::getTitleInfos(const ucstring &titleId, bo
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
|
|
|
const ucchar *CStringManagerClient::getClassificationTypeLocalizedName(EGSPD::CClassificationType::TClassificationType type)
|
|
|
|
const char *CStringManagerClient::getClassificationTypeLocalizedName(EGSPD::CClassificationType::TClassificationType type)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return getSpecialDesc(EGSPD::CClassificationType::toString(type));
|
|
|
|
return getSpecialDesc(EGSPD::CClassificationType::toString(type));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
|
|
|
const ucchar *CStringManagerClient::getOutpostLocalizedName(NLMISC::CSheetId id)
|
|
|
|
const char *CStringManagerClient::getOutpostLocalizedName(NLMISC::CSheetId id)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return getSpecialWord(id.toString());
|
|
|
|
return getSpecialWord(id.toString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
|
|
|
const ucchar *CStringManagerClient::getOutpostLocalizedDescription(NLMISC::CSheetId id)
|
|
|
|
const char *CStringManagerClient::getOutpostLocalizedDescription(NLMISC::CSheetId id)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return getSpecialDesc(id.toString());
|
|
|
|
return getSpecialDesc(id.toString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
|
|
|
const ucchar *CStringManagerClient::getOutpostBuildingLocalizedName(NLMISC::CSheetId id)
|
|
|
|
const char *CStringManagerClient::getOutpostBuildingLocalizedName(NLMISC::CSheetId id)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return getSpecialWord(id.toString());
|
|
|
|
return getSpecialWord(id.toString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
|
|
|
const ucchar *CStringManagerClient::getOutpostBuildingLocalizedDescription(NLMISC::CSheetId id)
|
|
|
|
const char *CStringManagerClient::getOutpostBuildingLocalizedDescription(NLMISC::CSheetId id)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return getSpecialDesc(id.toString());
|
|
|
|
return getSpecialDesc(id.toString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
|
|
|
const ucchar *CStringManagerClient::getSquadLocalizedName(NLMISC::CSheetId id)
|
|
|
|
const char *CStringManagerClient::getSquadLocalizedName(NLMISC::CSheetId id)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return getSpecialWord(id.toString());
|
|
|
|
return getSpecialWord(id.toString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
|
|
|
const ucchar *CStringManagerClient::getSquadLocalizedDescription(NLMISC::CSheetId id)
|
|
|
|
const char *CStringManagerClient::getSquadLocalizedDescription(NLMISC::CSheetId id)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return getSpecialDesc(id.toString());
|
|
|
|
return getSpecialDesc(id.toString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
|
|
|
void CStringManagerClient::replaceDynString(const ucstring &name, const ucstring &text)
|
|
|
|
void CStringManagerClient::replaceDynString(const std::string &name, const std::string &text)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_DynStrings[name] = text;
|
|
|
|
_DynStrings[name] = text;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
|
|
|
void CStringManagerClient::replaceSBrickName(NLMISC::CSheetId id, const ucstring &name, const ucstring &desc, const ucstring &desc2)
|
|
|
|
void CStringManagerClient::replaceSBrickName(NLMISC::CSheetId id, const std::string &name, const std::string &desc, const std::string &desc2)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
std::string label= id.toString();
|
|
|
|
string label= id.toString();
|
|
|
|
if (label.empty())
|
|
|
|
if (label.empty())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// avoid case problems
|
|
|
|
// avoid case problems
|
|
|
|
static std::string lwrLabel;
|
|
|
|
static string lwrLabel;
|
|
|
|
lwrLabel = toLower(label);
|
|
|
|
lwrLabel = toLower(label);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
nlassert(!_SpecItem_MemoryCompressed); // Not allowed, strings are released!
|
|
|
|
if (_SpecItem_MemoryCompressed)
|
|
|
|
if (_SpecItem_MemoryCompressed)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ucchar *strName = (ucchar *)name.c_str();
|
|
|
|
#if 0
|
|
|
|
ucchar *strDesc = (ucchar *)desc.c_str();
|
|
|
|
const char *strName = name.c_str();
|
|
|
|
ucchar *strDesc2 = (ucchar *)desc2.c_str();
|
|
|
|
const char *strDesc = desc.c_str();
|
|
|
|
|
|
|
|
const char *strDesc2 = desc2.c_str();
|
|
|
|
CItemLight tmp;
|
|
|
|
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());
|
|
|
|
vector<CItemLight>::iterator it = lower_bound(_SpecItems.begin(), _SpecItems.end(), tmp, CItemLightComp());
|
|
|
|
|
|
|
|
|
|
|
|
if (it != _SpecItems.end())
|
|
|
|
if (it != _SpecItems.end())
|
|
|
@ -1773,6 +1775,7 @@ void CStringManagerClient::replaceSBrickName(NLMISC::CSheetId id, const ucstring
|
|
|
|
tmp.Desc2 = strDesc2;
|
|
|
|
tmp.Desc2 = strDesc2;
|
|
|
|
_SpecItems.push_back(tmp);
|
|
|
|
_SpecItems.push_back(tmp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|