Merge with develop

This commit is contained in:
kervala 2016-10-30 16:52:02 +01:00
parent 17d2b19525
commit 7a1a082135
41 changed files with 382 additions and 375 deletions

View file

@ -21,7 +21,7 @@
namespace STRING_MANAGER namespace STRING_MANAGER
{ {
const ucstring nl("\r\n"); const ucstring nl("\n");
struct TStringInfo struct TStringInfo

View file

@ -162,11 +162,8 @@ public:
* EF,BB, BF. * EF,BB, BF.
* 16 bits encoding can be recognized by the official header : * 16 bits encoding can be recognized by the official header :
* FF, FE, witch can be reversed if the data are MSB first. * FF, FE, witch can be reversed if the data are MSB first.
*
* Optionally, you can force the reader to consider the file as
* UTF-8 encoded.
*/ */
static void readTextBuffer(uint8 *buffer, uint size, ucstring &result, bool forceUtf8 = false); static void readTextBuffer(uint8 *buffer, uint size, ucstring &result);
/** Remove any C style comment from the passed string. /** Remove any C style comment from the passed string.
*/ */

View file

@ -442,8 +442,15 @@ void CCocoaEventEmitter::submitEvents(CEventServer& server, bool /* allWins */)
processMessage(event, &server); processMessage(event, &server);
} }
// forward the event to the cocoa application @try
[NSApp sendEvent:event]; {
// forward the event to the cocoa application
[NSApp sendEvent:event];
}
@catch(NSException *e)
{
nlwarning("Exception when sending event: %s", [[e reason] UTF8String]);
}
} }
_server = &server; _server = &server;

View file

@ -457,7 +457,7 @@ CFontGenerator::CFontGenerator (const std::string &fontFileName, const std::stri
nlerror ("FT_New_Face() failed with file '%s': %s", fontFileName.c_str(), getFT2Error(error)); nlerror ("FT_New_Face() failed with file '%s': %s", fontFileName.c_str(), getFT2Error(error));
} }
if (fontExFileName != "") if (!fontExFileName.empty())
{ {
error = FT_Attach_File (_Face, fontExFileName.c_str ()); error = FT_Attach_File (_Face, fontExFileName.c_str ());
if (error) if (error)

View file

@ -213,9 +213,9 @@ void CLandscapeUser::refreshAllZonesAround(const CVector &pos, float radius, std
refreshZonesAround (pos, radius, za, zr); refreshZonesAround (pos, radius, za, zr);
// some zone added or removed?? // some zone added or removed??
if(za != "") if(!za.empty())
zonesAdded.push_back(za); zonesAdded.push_back(za);
if(zr != "") if(!zr.empty())
zonesRemoved.push_back(zr); zonesRemoved.push_back(zr);
_ZoneManager.checkZonesAround ((uint)pos.x, (uint)(-pos.y), (uint)radius); _ZoneManager.checkZonesAround ((uint)pos.x, (uint)(-pos.y), (uint)radius);

View file

@ -1121,7 +1121,7 @@ void CInstanceGroup::setClusterSystemForInstances(CInstanceGroup *pIG)
void CInstanceGroup::getDynamicPortals (std::vector<std::string> &names) void CInstanceGroup::getDynamicPortals (std::vector<std::string> &names)
{ {
for (uint32 i = 0; i < _Portals.size(); ++i) for (uint32 i = 0; i < _Portals.size(); ++i)
if (_Portals[i].getName() != "") if (!_Portals[i].getName().empty())
names.push_back (_Portals[i].getName()); names.push_back (_Portals[i].getName());
} }

View file

@ -572,7 +572,7 @@ namespace NLGUI
curl_easy_cleanup(it->curl); curl_easy_cleanup(it->curl);
string tmpfile = it->dest + ".tmp"; string tmpfile = it->dest + ".tmp";
if(res != CURLE_OK || r < 200 || r >= 300 || ((it->md5sum != "") && (it->md5sum != getMD5(tmpfile).toString()))) if(res != CURLE_OK || r < 200 || r >= 300 || (!it->md5sum.empty() && (it->md5sum != getMD5(tmpfile).toString())))
{ {
NLMISC::CFile::deleteFile(tmpfile.c_str()); NLMISC::CFile::deleteFile(tmpfile.c_str());
} }

View file

@ -1430,7 +1430,7 @@ namespace NLGUI
// Append to the last line // Append to the last line
_Lines.back()->addWord(ucCurrentWord, 0, wordFormat, _FontWidth, *TextContext); _Lines.back()->addWord(ucCurrentWord, 0, wordFormat, _FontWidth, *TextContext);
// reset the word // reset the word
ucCurrentWord = ucstring(""); ucCurrentWord.clear();
} }

View file

@ -442,7 +442,7 @@ namespace NLGUI
if (sZeStart[sZeStart.size()-1] == ':') if (sZeStart[sZeStart.size()-1] == ':')
sZeStart = sZeStart.substr(0, sZeStart.size()-1); sZeStart = sZeStart.substr(0, sZeStart.size()-1);
while (sZeStart != "") while (!sZeStart.empty())
{ {
if (sEltId[0] == ':') if (sEltId[0] == ':')
sTmp = sZeStart + sEltId; sTmp = sZeStart + sEltId;

View file

@ -117,7 +117,7 @@ bool loadStringFile(const std::string filename, vector<TStringInfo> &stringInfos
*/ */
ucstring text; ucstring text;
CI18N::readTextFile(filename, text, false, false, true, CI18N::LINE_FMT_CRLF); CI18N::readTextFile(filename, text, false, false, true, CI18N::LINE_FMT_LF);
// CI18N::readTextBuffer(buffer, size, text); // CI18N::readTextBuffer(buffer, size, text);
// delete [] buffer; // delete [] buffer;
@ -154,7 +154,7 @@ bool loadStringFile(const std::string filename, vector<TStringInfo> &stringInfos
if (!CI18N::parseLabel(first, last, si.Identifier)) if (!CI18N::parseLabel(first, last, si.Identifier))
{ {
uint32 line = countLine(text, first); uint32 line = countLine(text, first);
nlwarning("DT: Fatal : In '%s', line %u: Invalid label after '%s'\n", nlwarning("DT: Fatal : In '%s', line %u: Invalid label after '%s'",
filename.c_str(), filename.c_str(),
line, line,
lastLabel.c_str()); lastLabel.c_str());
@ -167,7 +167,7 @@ bool loadStringFile(const std::string filename, vector<TStringInfo> &stringInfos
if (!CI18N::parseMarkedString(openMark, closeMark, first, last, si.Text)) if (!CI18N::parseMarkedString(openMark, closeMark, first, last, si.Text))
{ {
uint32 line = countLine(text, first); uint32 line = countLine(text, first);
nlwarning("DT: Fatal : In '%s', line %u: Invalid text value for label %s\n", nlwarning("DT: Fatal : In '%s', line %u: Invalid text value for label %s",
filename.c_str(), filename.c_str(),
line, line,
lastLabel.c_str()); lastLabel.c_str());
@ -181,7 +181,7 @@ bool loadStringFile(const std::string filename, vector<TStringInfo> &stringInfos
if (!CI18N::parseMarkedString(openMark, closeMark, first, last, si.Text2)) if (!CI18N::parseMarkedString(openMark, closeMark, first, last, si.Text2))
{ {
uint32 line = countLine(text, first); uint32 line = countLine(text, first);
nlwarning("DT: Fatal: In '%s' line %u: Invalid text2 value label %s\n", nlwarning("DT: Fatal: In '%s' line %u: Invalid text2 value label %s",
filename.c_str(), filename.c_str(),
line, line,
lastLabel.c_str()); lastLabel.c_str());
@ -313,7 +313,7 @@ bool readPhraseFile(const std::string &filename, vector<TPhrase> &phrases, bool
{ {
ucstring doc; ucstring doc;
CI18N::readTextFile(filename, doc, false, false, true, CI18N::LINE_FMT_CRLF); CI18N::readTextFile(filename, doc, false, false, true, CI18N::LINE_FMT_LF);
return readPhraseFileFromString(doc, filename, phrases, forceRehash); return readPhraseFileFromString(doc, filename, phrases, forceRehash);
} }
@ -577,7 +577,7 @@ ucstring preparePhraseFile(const vector<TPhrase> &phrases, bool removeDiffCommen
if (!c.Comments.empty()) if (!c.Comments.empty())
{ {
ucstring comment = tabLines(1, c.Comments); ucstring comment = tabLines(1, c.Comments);
ret += comment; // + '\r'+'\n'; ret += comment; // + '\n';
} }
if (!c.Conditions.empty()) if (!c.Conditions.empty())
{ {
@ -626,7 +626,7 @@ bool loadExcelSheet(const string filename, TWorksheet &worksheet, bool checkUniq
fp.close(); fp.close();
ucstring str; ucstring str;
CI18N::readTextFile(filename, str, false, false, false, CI18N::LINE_FMT_CRLF); CI18N::readTextFile(filename, str, false, false, false, CI18N::LINE_FMT_LF);
if (!readExcelSheet(str, worksheet, checkUnique)) if (!readExcelSheet(str, worksheet, checkUnique))
return false; return false;
@ -646,6 +646,8 @@ bool readExcelSheet(const ucstring &str, TWorksheet &worksheet, bool checkUnique
strArray[strArray.size()-1]= 0; strArray[strArray.size()-1]= 0;
memcpy(&strArray[0], &str[0], str.size()*sizeof(ucchar)); memcpy(&strArray[0], &str[0], str.size()*sizeof(ucchar));
// size of new line characters
size_t sizeOfNl = nl.length();
// **** Build array of lines. just point to strArray, and fill 0 where appropriated // **** Build array of lines. just point to strArray, and fill 0 where appropriated
vector<ucchar*> lines; vector<ucchar*> lines;
@ -660,10 +662,10 @@ bool readExcelSheet(const ucstring &str, TWorksheet &worksheet, bool checkUnique
// nldebug("Found line : [%s]", ucstring(&strArray[lastPos]).toString().c_str()); // nldebug("Found line : [%s]", ucstring(&strArray[lastPos]).toString().c_str());
lines.push_back(&strArray[lastPos]); lines.push_back(&strArray[lastPos]);
} }
lastPos = pos + 2; lastPos = pos + sizeOfNl;
} }
// Must add last line if no \r\n ending // Must add last line if no \n ending
if (lastPos < str.size()) if (lastPos < str.size())
{ {
pos= str.size(); pos= str.size();

View file

@ -743,7 +743,7 @@ void CI18N::_readTextFile(const string &filename,
// Transform the string in ucstring according to format header // Transform the string in ucstring according to format header
if (!text.empty()) if (!text.empty())
readTextBuffer((uint8*)&text[0], (uint)text.size(), result, forceUtf8); readTextBuffer((uint8*)&text[0], (uint)text.size(), result);
if (preprocess) if (preprocess)
{ {
@ -1109,7 +1109,7 @@ void CI18N::_readTextFile(const string &filename,
temp.append(result.begin()+lastPos, result.end()); temp.append(result.begin()+lastPos, result.end());
result.swap(temp); result.swap(temp);
temp = ""; temp.clear();
// second loop with the '\n' // second loop with the '\n'
pos = 0; pos = 0;
@ -1137,28 +1137,13 @@ void CI18N::_readTextFile(const string &filename,
} }
} }
void CI18N::readTextBuffer(uint8 *buffer, uint size, ucstring &result, bool forceUtf8) void CI18N::readTextBuffer(uint8 *buffer, uint size, ucstring &result)
{ {
static uint8 utf16Header[] = { 0xffu, 0xfeu }; static uint8 utf16Header[] = { 0xffu, 0xfeu };
static uint8 utf16RevHeader[] = { 0xfeu, 0xffu }; static uint8 utf16RevHeader[] = { 0xfeu, 0xffu };
static uint8 utf8Header[] = { 0xefu, 0xbbu, 0xbfu }; static uint8 utf8Header[] = { 0xefu, 0xbbu, 0xbfu };
if (forceUtf8) if (size>=3 &&
{
if (size>=3 &&
buffer[0]==utf8Header[0] &&
buffer[1]==utf8Header[1] &&
buffer[2]==utf8Header[2]
)
{
// remove utf8 header
buffer+= 3;
size-=3;
}
string text((char*)buffer, size);
result.fromUtf8(text);
}
else if (size>=3 &&
buffer[0]==utf8Header[0] && buffer[0]==utf8Header[0] &&
buffer[1]==utf8Header[1] && buffer[1]==utf8Header[1] &&
buffer[2]==utf8Header[2] buffer[2]==utf8Header[2]
@ -1211,10 +1196,9 @@ void CI18N::readTextBuffer(uint8 *buffer, uint size, ucstring &result, bool forc
} }
else else
{ {
// hum.. ascii read ? // all text files without BOM are now parsed as UTF-8 by default
// so, just do a direct conversion
string text((char*)buffer, size); string text((char*)buffer, size);
result = text; result.fromUtf8(text);
} }
} }

View file

@ -2504,13 +2504,13 @@ class CHandlerInvCanDropTo : public IActionHandler
if (pCSDst != NULL) if (pCSDst != NULL)
{ {
// If we want to drop something on a reference slot (hand or equip) // If we want to drop something on a reference slot (hand or equip)
if (pInv->getDBIndexPath(pCSDst) != "") if (!pInv->getDBIndexPath(pCSDst).empty())
{ {
// We must drag'n'drop an item // We must drag'n'drop an item
if (pCSSrc && pCSSrc->getType() == CCtrlSheetInfo::SheetType_Item) if (pCSSrc && pCSSrc->getType() == CCtrlSheetInfo::SheetType_Item)
if (pCSDst && pCSDst->getType() == CCtrlSheetInfo::SheetType_Item) if (pCSDst && pCSDst->getType() == CCtrlSheetInfo::SheetType_Item)
{ {
if (pInv->getDBIndexPath(pCSSrc) != "") if (!pInv->getDBIndexPath(pCSSrc).empty())
{ {
// The item dragged comes from a slot check if this is the good type // The item dragged comes from a slot check if this is the good type
if (pCSDst->canDropItem(pCSSrc)) if (pCSDst->canDropItem(pCSSrc))

View file

@ -52,7 +52,7 @@ void CItemConsumableEffectHelper::getItemConsumableEffectText(const CItemSheet *
// Extract parameters from sheet // Extract parameters from sheet
vector<CSString> params; vector<CSString> params;
CSString param = eff.splitTo(':', true); CSString param = eff.splitTo(':', true);
while (param != "") while (!param.empty())
{ {
params.push_back(param); params.push_back(param);
param = eff.splitTo(':', true); param = eff.splitTo(':', true);

View file

@ -346,13 +346,13 @@ static CLuaString lstr_isNil("isNil");
void CLuaIHMRyzom::createLuaEnumTable(CLuaState &ls, const std::string &str) void CLuaIHMRyzom::createLuaEnumTable(CLuaState &ls, const std::string &str)
{ {
//H_AUTO(Lua_CLuaIHM_createLuaEnumTable) //H_AUTO(Lua_CLuaIHM_createLuaEnumTable)
std::string path = "", script, p; std::string path, script, p;
CSString s = str; CSString s = str;
// Create table recursively (ex: 'game.TPVPClan' will check/create the table 'game' and 'game.TPVPClan') // Create table recursively (ex: 'game.TPVPClan' will check/create the table 'game' and 'game.TPVPClan')
p = s.splitTo('.', true); p = s.splitTo('.', true);
while (p.size() > 0) while (p.size() > 0)
{ {
if (path == "") if (path.empty())
path = p; path = p;
else else
path += "." + p; path += "." + p;

View file

@ -128,7 +128,7 @@ void CViewBitmapFaberMp::draw ()
{ {
CItemSheet *pIS = (CItemSheet*)pES; CItemSheet *pIS = (CItemSheet*)pES;
if (pIS->getIconBack() != "") if (!pIS->getIconBack().empty())
{ {
if (_AccIconBackString != pIS->getIconBack()) if (_AccIconBackString != pIS->getIconBack())
{ {
@ -140,7 +140,7 @@ void CViewBitmapFaberMp::draw ()
_AccIconBackId); _AccIconBackId);
} }
if (pIS->getIconMain() != "") if (!pIS->getIconMain().empty())
{ {
if (_AccIconMainString != pIS->getIconMain()) if (_AccIconMainString != pIS->getIconMain())
{ {
@ -152,7 +152,7 @@ void CViewBitmapFaberMp::draw ()
_AccIconMainId); _AccIconMainId);
} }
if (pIS->getIconOver() != "") if (!pIS->getIconOver().empty())
{ {
if (_AccIconOverString != pIS->getIconOver()) if (_AccIconOverString != pIS->getIconOver())
{ {

View file

@ -507,7 +507,7 @@ void impulseShardId(NLMISC::CBitMemStream &impulse)
string webHost; string webHost;
impulse.serial(webHost); impulse.serial(webHost);
if (webHost != "") if (!webHost.empty())
{ {
WebServer = webHost; WebServer = webHost;
} }

View file

@ -125,7 +125,7 @@ const CObject *CPropertyAccessor::getPropertyValue(const CObject* componentParam
std::string str = propClass->toString(); std::string str = propClass->toString();
while (!toRet && str != "") while (!toRet && !str.empty())
{ {
CObjectGenerator* generator = _Factory->getGenerator(str); CObjectGenerator* generator = _Factory->getGenerator(str);

View file

@ -503,7 +503,7 @@ void CRosace::init()
void CRosace::add(const string &name, const CRosaceContext &context) void CRosace::add(const string &name, const CRosaceContext &context)
{ {
// If the name is not empty. // If the name is not empty.
if(name != "") if(!name.empty())
_Contexts.insert(TContexts::value_type (name, context)); _Contexts.insert(TContexts::value_type (name, context));
}// add // }// add //

View file

@ -647,7 +647,7 @@ bool CObjectString::set(const std::string& key, const std::string & value)
{ {
//H_AUTO(R2_CObjectString_set) //H_AUTO(R2_CObjectString_set)
BOMB_IF( key != "", "Try to set the a sub value of an object that does not allowed it", return false); BOMB_IF(!key.empty(), "Try to set the a sub value of an object that does not allowed it", return false);
_Value = value; _Value = value;
return true; return true;
} }
@ -808,7 +808,7 @@ bool CObjectNumber::set(const std::string& key, double value)
{ {
//H_AUTO(R2_CObjectNumber_set) //H_AUTO(R2_CObjectNumber_set)
BOMB_IF(key != "", "Try to set an element of a table on an object that is not a table", return false); BOMB_IF(!key.empty(), "Try to set an element of a table on an object that is not a table", return false);
_Value = value; _Value = value;
return true; return true;
@ -819,7 +819,7 @@ bool CObjectNumber::set(const std::string& key, const std::string & value)
{ {
//H_AUTO(R2_CObjectNumber_set) //H_AUTO(R2_CObjectNumber_set)
//XXX //XXX
BOMB_IF(key != "", "Try to set an element of a table on an object that is not a table", return false); BOMB_IF(!key.empty(), "Try to set an element of a table on an object that is not a table", return false);
NLMISC::fromString(value, _Value); NLMISC::fromString(value, _Value);
return true; return true;
} }
@ -907,7 +907,7 @@ bool CObjectInteger::set(const std::string& key, sint64 value)
{ {
//H_AUTO(R2_CObjectInteger_set) //H_AUTO(R2_CObjectInteger_set)
BOMB_IF(key != "", "Try to set an element of a table on an object that is not a table", return false); BOMB_IF(!key.empty(), "Try to set an element of a table on an object that is not a table", return false);
_Value = value; _Value = value;
return true; return true;
@ -918,7 +918,7 @@ bool CObjectInteger::set(const std::string& key, const std::string & value)
{ {
//H_AUTO(R2_CObjectInteger_set) //H_AUTO(R2_CObjectInteger_set)
//XXX //XXX
BOMB_IF(key != "", "Try to set an element of a table on an object that is not a table", return false); BOMB_IF(!key.empty(), "Try to set an element of a table on an object that is not a table", return false);
NLMISC::fromString(value, _Value); NLMISC::fromString(value, _Value);
return true; return true;
} }

View file

@ -2813,7 +2813,7 @@ void CServerEditionModule::createSession(NLNET::IModuleProxy *sender, TCharId ow
else if (first->first == "Rules" ) { info.setDMLess( first->second != "Mastered"); } else if (first->first == "Rules" ) { info.setDMLess( first->second != "Mastered"); }
else if (first->first == "NevraxScenario" && first->second == "1") { nevraxScenario = true; } else if (first->first == "NevraxScenario" && first->second == "1") { nevraxScenario = true; }
else if (first->first == "TrialAllowed" && first->second == "1") { trialAllowed = true; } else if (first->first == "TrialAllowed" && first->second == "1") { trialAllowed = true; }
else if (first->first == "MissionTag" && first->second != "") { missionTag = first->second; } else if (first->first == "MissionTag" && !first->second.empty()) { missionTag = first->second; }
} }
// info.setMissionTag(missionTag); // info.setMissionTag(missionTag);
info.setSessionAnimatorCharId( ownerCharId); info.setSessionAnimatorCharId( ownerCharId);
@ -3863,7 +3863,7 @@ void CServerEditionModule::startScenario(NLNET::IModuleProxy *senderModuleProxy,
else if (first->first == "Rules" ) { info.setDMLess( first->second != "Mastered"); } else if (first->first == "Rules" ) { info.setDMLess( first->second != "Mastered"); }
else if (first->first == "NevraxScenario" && first->second == "1") { nevraxScenario = true; } else if (first->first == "NevraxScenario" && first->second == "1") { nevraxScenario = true; }
else if (first->first == "TrialAllowed" && first->second == "1") { trialAllowed = true; } else if (first->first == "TrialAllowed" && first->second == "1") { trialAllowed = true; }
else if (first->first == "MissionTag" && first->second != "") { missionTag = first->second; } else if (first->first == "MissionTag" && !first->second.empty()) { missionTag = first->second; }
} }
info.setSessionAnimatorCharId( charId); info.setSessionAnimatorCharId( charId);

View file

@ -479,14 +479,14 @@ void CStringManagerModule::translateAndForwardWithArg(TDataSetRow senderId,CChat
void CStringManagerModule::translateAndForward(TDataSetRow senderId,CChatGroup::TGroupType groupType,std::string id,TSessionId sessionId) void CStringManagerModule::translateAndForward(TDataSetRow senderId,CChatGroup::TGroupType groupType,std::string id,TSessionId sessionId)
{ {
std::string toSend = getValue(sessionId.asInt(), id); std::string toSend = getValue(sessionId.asInt(), id);
if(toSend != "") if(!toSend.empty())
send(senderId,groupType,toSend); send(senderId,groupType,toSend);
} }
void CStringManagerModule::send(TDataSetRow& senderId,CChatGroup::TGroupType groupType,const std::string& toSend) void CStringManagerModule::send(TDataSetRow& senderId,CChatGroup::TGroupType groupType,const std::string& toSend)
{ {
if(toSend != "") if(!toSend.empty())
{ {
ucstring uStr; ucstring uStr;
uStr.fromUtf8(toSend); uStr.fromUtf8(toSend);

View file

@ -2071,7 +2071,7 @@ public:
_WorldMap.clear(); _WorldMap.clear();
string ext = CFile::getExtension(name); string ext = CFile::getExtension(name);
if (ext == "") if (ext.empty())
ext = "cwmap2"; ext = "cwmap2";
CIFile f(OutputPath+CFile::getFilenameWithoutExtension(name)+"."+ext); CIFile f(OutputPath+CFile::getFilenameWithoutExtension(name)+"."+ext);
f.serial(_WorldMap); f.serial(_WorldMap);
@ -2213,7 +2213,7 @@ public:
_WorldMap.clear(); _WorldMap.clear();
string ext = CFile::getExtension(name); string ext = CFile::getExtension(name);
if (ext == "") if (ext.empty())
ext = "cw_map2"; ext = "cw_map2";
CIFile f(CFile::getPath(name) + CFile::getFilenameWithoutExtension(name)+"."+ext); CIFile f(CFile::getPath(name) + CFile::getFilenameWithoutExtension(name)+"."+ext);

View file

@ -288,6 +288,8 @@ void CConfig::setString( const char *key, const std::string &value )
} }
else else
{ {
nlwarning( "Couldn't find key %s in %s.", key, cf.getFilename().c_str() ); NLMISC::CConfigFile::CVar var;
var.forceAsString(value);
cf.insertVar(key, var);
} }
} }

View file

@ -25,11 +25,16 @@ CSoundSettingsWidget::CSoundSettingsWidget( QWidget *parent ) :
setupUi( this ); setupUi( this );
load(); load();
connect(autoRadioButton, SIGNAL(clicked(bool)), this, SLOT(onSomethingChanged()));
connect(openalRadioButton, SIGNAL(clicked(bool)), this, SLOT(onSomethingChanged()));
connect(fmodRadioButton, SIGNAL(clicked(bool)), this, SLOT(onSomethingChanged()));
connect(xaudio2RadioButton, SIGNAL(clicked(bool)), this, SLOT(onSomethingChanged()));
connect(directsoundRadioButton, SIGNAL(clicked(bool)), this, SLOT(onSomethingChanged()));
connect( tracksSlider, SIGNAL( valueChanged( int ) ), this, SLOT( onTracksSliderChange() ) ); connect( tracksSlider, SIGNAL( valueChanged( int ) ), this, SLOT( onTracksSliderChange() ) );
connect( soundCheckBox, SIGNAL( clicked( bool ) ), this, SLOT( onSomethingChanged() ) ); connect( soundCheckBox, SIGNAL( clicked( bool ) ), this, SLOT( onSomethingChanged() ) );
connect( eaxCheckBox, SIGNAL( clicked( bool ) ), this, SLOT( onSomethingChanged() ) ); connect( eaxCheckBox, SIGNAL( clicked( bool ) ), this, SLOT( onSomethingChanged() ) );
connect( softwareCheckBox, SIGNAL( clicked( bool ) ), this, SLOT( onSomethingChanged() ) ); connect( softwareCheckBox, SIGNAL( clicked( bool ) ), this, SLOT( onSomethingChanged() ) );
connect( fmodCheckBox, SIGNAL( clicked( bool ) ), this, SLOT( onSomethingChanged() ) );
} }
CSoundSettingsWidget::~CSoundSettingsWidget() CSoundSettingsWidget::~CSoundSettingsWidget()
@ -64,8 +69,38 @@ void CSoundSettingsWidget::load()
updateTracksLabel(); updateTracksLabel();
if( s.config.getString( "DriverSound" ).compare( "FMod" ) == 0 ) std::string soundDriver = NLMISC::toLower(s.config.getString("DriverSound"));
fmodCheckBox->setChecked( true );
#ifdef Q_OS_WIN32
fmodRadioButton->setEnabled(true);
xaudio2RadioButton->setEnabled(true);
directsoundRadioButton->setEnabled(true);
#else
fmodRadioButton->setEnabled(false);
xaudio2RadioButton->setEnabled(false);
directsoundRadioButton->setEnabled(false);
#endif
if (soundDriver.compare("openal") == 0)
{
openalRadioButton->setChecked(true);
}
else if (soundDriver.compare("fmod") == 0)
{
fmodRadioButton->setChecked(true);
}
else if (soundDriver.compare("xaudio2") == 0)
{
xaudio2RadioButton->setChecked(true);
}
else if (soundDriver.compare("directsound") == 0)
{
directsoundRadioButton->setChecked(true);
}
else
{
autoRadioButton->setChecked(true);
}
} }
void CSoundSettingsWidget::save() void CSoundSettingsWidget::save()
@ -83,8 +118,18 @@ void CSoundSettingsWidget::save()
s.config.setInt( "MaxTrack", tracksSlider->value() * 4 ); s.config.setInt( "MaxTrack", tracksSlider->value() * 4 );
if( fmodCheckBox->isChecked() ) if (openalRadioButton->isChecked())
s.config.setString( "DriverSound", std::string( "FMod" ) ); s.config.setString("DriverSound", std::string("OpenAL"));
#ifdef Q_OS_WIN32
else if (fmodRadioButton->isChecked())
s.config.setString("DriverSound", std::string("FMod"));
else if (xaudio2RadioButton->isChecked())
s.config.setString("DriverSound", std::string("XAudio2"));
else if (directsoundRadioButton->isChecked())
s.config.setString("DriverSound", std::string("DirectSound"));
#endif
else
s.config.setString("DriverSound", std::string("Auto"));
} }
void CSoundSettingsWidget::updateTracksLabel() void CSoundSettingsWidget::updateTracksLabel()

View file

@ -7,62 +7,58 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>391</width> <width>391</width>
<height>429</height> <height>388</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Display</string> <string>Display</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout_2"> <layout class="QVBoxLayout" name="verticalLayout_2">
<item row="0" column="0"> <item>
<widget class="QGroupBox" name="driverGroupBox"> <widget class="QGroupBox" name="driverGroupBox">
<property name="title"> <property name="title">
<string>Driver</string> <string>Driver</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QVBoxLayout" name="verticalLayout_4">
<item row="0" column="0"> <item>
<layout class="QVBoxLayout" name="verticalLayout_4"> <widget class="QLabel" name="videoDriverLabel">
<item> <property name="text">
<widget class="QLabel" name="label"> <string>Specify if Ryzom is to be run in OpenGL or Direct3D:</string>
<property name="text"> </property>
<string>Specify if Ryzom is to be run in OpenGL or Direct3D:</string> </widget>
</property> </item>
</widget> <item>
</item> <widget class="QRadioButton" name="autoRadioButton">
<item> <property name="text">
<widget class="QRadioButton" name="autoRadioButton"> <string>Auto</string>
<property name="text"> </property>
<string>Auto</string> </widget>
</property> </item>
</widget> <item>
</item> <widget class="QRadioButton" name="openglRadioButton">
<item> <property name="text">
<widget class="QRadioButton" name="openglRadioButton"> <string>OpenGL</string>
<property name="text"> </property>
<string>OpenGL</string> </widget>
</property> </item>
</widget> <item>
</item> <widget class="QRadioButton" name="direct3dRadioButton">
<item> <property name="text">
<widget class="QRadioButton" name="direct3dRadioButton"> <string>Direct3D</string>
<property name="text"> </property>
<string>Direct3D</string> </widget>
</property>
</widget>
</item>
</layout>
</item> </item>
</layout> </layout>
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item>
<widget class="QGroupBox" name="parametersGroupBox"> <widget class="QGroupBox" name="parametersGroupBox">
<property name="title"> <property name="title">
<string>Parameters</string> <string>Parameters</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_3"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<widget class="QLabel" name="label_2"> <widget class="QLabel" name="windowedLabel">
<property name="text"> <property name="text">
<string>Specify if Ryzom is to be run in full screen or window mode:</string> <string>Specify if Ryzom is to be run in full screen or window mode:</string>
</property> </property>
@ -76,7 +72,7 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QLabel" name="label_3"> <widget class="QLabel" name="videoModeLabel">
<property name="text"> <property name="text">
<string>Specify a video mode:</string> <string>Specify a video mode:</string>
</property> </property>
@ -85,19 +81,6 @@
<item> <item>
<widget class="QComboBox" name="videomodeComboBox"/> <widget class="QComboBox" name="videomodeComboBox"/>
</item> </item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>34</height>
</size>
</property>
</spacer>
</item>
<item> <item>
<widget class="QRadioButton" name="windowedRadioButton"> <widget class="QRadioButton" name="windowedRadioButton">
<property name="text"> <property name="text">
@ -106,54 +89,46 @@
</widget> </widget>
</item> </item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QFormLayout" name="windowFormLayout">
<item> <item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout_2"> <widget class="QLabel" name="widthLabel">
<item> <property name="text">
<widget class="QLabel" name="label_4"> <string>Width</string>
<property name="text"> </property>
<string>Width</string> </widget>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>Height</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_6">
<property name="text">
<string>X position</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_7">
<property name="text">
<string>Y position</string>
</property>
</widget>
</item>
</layout>
</item> </item>
<item> <item row="0" column="1">
<layout class="QVBoxLayout" name="verticalLayout"> <widget class="QLineEdit" name="widthLineEdit"/>
<item> </item>
<widget class="QLineEdit" name="widthLineEdit"/> <item row="1" column="0">
</item> <widget class="QLabel" name="heightLabel">
<item> <property name="text">
<widget class="QLineEdit" name="heightLineEdit"/> <string>Height</string>
</item> </property>
<item> </widget>
<widget class="QLineEdit" name="xpositionLineEdit"/> </item>
</item> <item row="1" column="1">
<item> <widget class="QLineEdit" name="heightLineEdit"/>
<widget class="QLineEdit" name="ypositionLineEdit"/> </item>
</item> <item row="2" column="0">
</layout> <widget class="QLabel" name="xLabel">
<property name="text">
<string>X position</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="xpositionLineEdit"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="yLabel">
<property name="text">
<string>Y position</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="ypositionLineEdit"/>
</item> </item>
</layout> </layout>
</item> </item>

View file

@ -6,147 +6,140 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>391</width> <width>294</width>
<height>429</height> <height>317</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Sound</string> <string>Sound</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QVBoxLayout" name="verticalLayout_3">
<item row="0" column="0"> <item>
<layout class="QVBoxLayout" name="verticalLayout_2"> <widget class="QGroupBox" name="driverGroupBox">
<item> <property name="title">
<layout class="QVBoxLayout" name="verticalLayout"> <string>Driver</string>
<item> </property>
<widget class="QCheckBox" name="soundCheckBox"> <layout class="QVBoxLayout" name="verticalLayout">
<property name="text"> <item>
<string>Enable sound</string> <widget class="QRadioButton" name="autoRadioButton">
</property> <property name="text">
</widget> <string>Auto</string>
</item> </property>
<item> </widget>
<widget class="QCheckBox" name="eaxCheckBox"> </item>
<property name="text"> <item>
<string>Enable EAX</string> <widget class="QRadioButton" name="openalRadioButton">
</property> <property name="text">
</widget> <string>OpenAL</string>
</item> </property>
<item> </widget>
<widget class="QCheckBox" name="fmodCheckBox"> </item>
<property name="text"> <item>
<string>Enable FMod</string> <widget class="QRadioButton" name="fmodRadioButton">
</property> <property name="text">
</widget> <string>FMod</string>
</item> </property>
<item> </widget>
<widget class="QCheckBox" name="softwareCheckBox"> </item>
<property name="text"> <item>
<string>Software sound buffer (may increase FPS)</string> <widget class="QRadioButton" name="xaudio2RadioButton">
</property> <property name="text">
</widget> <string>XAudio2</string>
</item> </property>
<item> </widget>
<spacer name="verticalSpacer"> </item>
<property name="orientation"> <item>
<enum>Qt::Vertical</enum> <widget class="QRadioButton" name="directsoundRadioButton">
</property> <property name="text">
<property name="sizeType"> <string>DirectSound</string>
<enum>QSizePolicy::Maximum</enum> </property>
</property> </widget>
<property name="sizeHint" stdset="0"> </item>
<size> </layout>
<width>20</width> </widget>
<height>13</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Sound tracks</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Maximum</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>18</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QSlider" name="tracksSlider">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>8</number>
</property>
<property name="singleStep">
<number>1</number>
</property>
<property name="pageStep">
<number>4</number>
</property>
<property name="value">
<number>1</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="tracksLabel">
<property name="text">
<string>8 tracks</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item> </item>
<item row="0" column="1"> <item>
<spacer name="horizontalSpacer"> <widget class="QGroupBox" name="parametersGroupBox">
<property name="orientation"> <property name="title">
<enum>Qt::Horizontal</enum> <string>Parameters</string>
</property> </property>
<property name="sizeHint" stdset="0"> <layout class="QVBoxLayout" name="verticalLayout_2">
<size> <item>
<width>180</width> <widget class="QCheckBox" name="soundCheckBox">
<height>20</height> <property name="text">
</size> <string>Enable sound</string>
</property> </property>
</spacer> </widget>
</item> </item>
<item row="1" column="0"> <item>
<spacer name="verticalSpacer_3"> <widget class="QCheckBox" name="eaxCheckBox">
<property name="orientation"> <property name="text">
<enum>Qt::Vertical</enum> <string>Enable EAX</string>
</property> </property>
<property name="sizeHint" stdset="0"> </widget>
<size> </item>
<width>20</width> <item>
<height>223</height> <widget class="QCheckBox" name="softwareCheckBox">
</size> <property name="text">
</property> <string>Software sound buffer (may increase FPS)</string>
</spacer> </property>
</widget>
</item>
<item>
<widget class="QLabel" name="soundTracksLabel">
<property name="text">
<string>Sound tracks</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="soundTracksHorizontalLayout">
<item>
<widget class="QSlider" name="tracksSlider">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>8</number>
</property>
<property name="singleStep">
<number>1</number>
</property>
<property name="pageStep">
<number>4</number>
</property>
<property name="value">
<number>1</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="tracksLabel">
<property name="text">
<string>8 tracks</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item> </item>
</layout> </layout>
</widget> </widget>

View file

@ -1158,7 +1158,7 @@ void CScreenshotIslands::loadIslands()
TBuffer cleanBuffer; TBuffer cleanBuffer;
processProximityBuffer(zoneBuffer, zones[i].getZoneWidth(), cleanBuffer); processProximityBuffer(zoneBuffer, zones[i].getZoneWidth(), cleanBuffer);
string fileName = string(""); string fileName;
list< string >::const_iterator itIsland(continent.Islands.begin()), lastIsland(continent.Islands.end()); list< string >::const_iterator itIsland(continent.Islands.begin()), lastIsland(continent.Islands.end());
for( ; itIsland != lastIsland ; ++itIsland) for( ; itIsland != lastIsland ; ++itIsland)
{ {
@ -1178,7 +1178,7 @@ void CScreenshotIslands::loadIslands()
} }
// write the processed proximity map to an output file // write the processed proximity map to an output file
if(fileName != "") if(!fileName.empty())
{ {
writeProximityBufferToTgaFile(fileName, cleanBuffer, zones[i].getZoneWidth(), zones[i].getZoneHeight()); writeProximityBufferToTgaFile(fileName, cleanBuffer, zones[i].getZoneWidth(), zones[i].getZoneHeight());
_TempFileNames.push_back(fileName); _TempFileNames.push_back(fileName);

View file

@ -167,7 +167,7 @@ public:
//--------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------
// housekeeping // housekeeping
if (outputName!="") if (!outputName.empty())
flush(outputName); flush(outputName);
} }
@ -258,7 +258,7 @@ private:
if (i>=cols.size() if (i>=cols.size()
|| i>=lastTblCols.size() || i>=lastTblCols.size()
|| cols[i]!=lastTblCols[i] || cols[i]!=lastTblCols[i]
|| (cols[i]!="" && !headerIsOpen[tblColumnNames[i]])) || (!cols[i].empty() && !headerIsOpen[tblColumnNames[i]]))
{ {
CSString s=headers[tblColumnNames[i]]; CSString s=headers[tblColumnNames[i]];
for (uint32 j=1;j<cols.size()&&j<tblColumnNames.size();++j) for (uint32 j=1;j<cols.size()&&j<tblColumnNames.size();++j)
@ -302,7 +302,7 @@ private:
} }
else if (keyword=="output") else if (keyword=="output")
{ {
if (outputName!="") if (!outputName.empty())
{ {
flush(outputName); flush(outputName);
} }
@ -399,7 +399,7 @@ private:
{ {
// do nothing // do nothing
} }
else if (keyword=="") else if (keyword.empty())
{ {
mode=DEFAULT; mode=DEFAULT;
closeFooters(); closeFooters();

View file

@ -642,42 +642,42 @@ bool CExport::newExport (SExportOptions &opt, IExportCB *expCB)
// Ok set parameters from options first and with CFG if no options set // Ok set parameters from options first and with CFG if no options set
if (_Options->OutIGDir == "") if (_Options->OutIGDir.empty())
_OutIGDir = CTools::normalizePath (ContinentCFG.OutIGDir); _OutIGDir = CTools::normalizePath (ContinentCFG.OutIGDir);
else else
_OutIGDir = CTools::normalizePath (_Options->OutIGDir); _OutIGDir = CTools::normalizePath (_Options->OutIGDir);
if (_Options->LandFile == "") if (_Options->LandFile.empty())
_LandFile = ContinentCFG.LandFile; _LandFile = ContinentCFG.LandFile;
else else
_LandFile = _Options->LandFile; _LandFile = _Options->LandFile;
if (_Options->DfnDir == "") if (_Options->DfnDir.empty())
_DfnDir = ContinentCFG.DfnDir; _DfnDir = ContinentCFG.DfnDir;
else else
_DfnDir = _Options->DfnDir; _DfnDir = _Options->DfnDir;
if (_Options->GameElemDir == "") if (_Options->GameElemDir.empty())
_GameElemDir = ContinentCFG.GameElemDir; _GameElemDir = ContinentCFG.GameElemDir;
else else
_GameElemDir = _Options->GameElemDir; _GameElemDir = _Options->GameElemDir;
if (_Options->InLandscapeDir == "") if (_Options->InLandscapeDir.empty())
_InLandscapeDir = ContinentCFG.LandZoneWDir; // Directory where to get .zonew files _InLandscapeDir = ContinentCFG.LandZoneWDir; // Directory where to get .zonew files
else else
_InLandscapeDir = _Options->InLandscapeDir; _InLandscapeDir = _Options->InLandscapeDir;
if (_Options->LandFarBankFile == "") if (_Options->LandFarBankFile.empty())
_LandBankFile = ContinentCFG.LandBankFile; // The .smallbank file associated with the landscape _LandBankFile = ContinentCFG.LandBankFile; // The .smallbank file associated with the landscape
else else
_LandBankFile = _Options->LandBankFile; _LandBankFile = _Options->LandBankFile;
if (_Options->LandFarBankFile == "") if (_Options->LandFarBankFile.empty())
_LandFarBankFile = ContinentCFG.LandFarBankFile; // The .farbank file _LandFarBankFile = ContinentCFG.LandFarBankFile; // The .farbank file
else else
_LandFarBankFile = _Options->LandFarBankFile; _LandFarBankFile = _Options->LandFarBankFile;
if (_Options->LandTileNoiseDir == "") if (_Options->LandTileNoiseDir.empty())
_LandTileNoiseDir = ContinentCFG.LandTileNoiseDir; // Directory where to get displacement map _LandTileNoiseDir = ContinentCFG.LandTileNoiseDir; // Directory where to get displacement map
else else
_LandTileNoiseDir = _Options->LandTileNoiseDir; _LandTileNoiseDir = _Options->LandTileNoiseDir;

View file

@ -27,7 +27,7 @@ using namespace NLMISC;
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
void CTools::mkdir (const string &dirName) void CTools::mkdir (const string &dirName)
{ {
if (dirName == "") if (dirName.empty())
return; return;
// Does the directory exist ? // Does the directory exist ?
string newDir = pwd(); string newDir = pwd();
@ -38,7 +38,7 @@ void CTools::mkdir (const string &dirName)
} }
SetCurrentDirectory (newDir.c_str()); SetCurrentDirectory (newDir.c_str());
// Create upper levels // Create upper levels
newDir = ""; newDir.clear();
string::size_type pos = dirName.rfind('\\'); string::size_type pos = dirName.rfind('\\');
if (pos != string::npos) if (pos != string::npos)
{ {

View file

@ -80,7 +80,7 @@ public:
return getNpcFullName(); return getNpcFullName();
else if (subPart == "function") else if (subPart == "function")
return _NpcFunction; return _NpcFunction;
else if (subPart == "") else if (subPart.empty())
return _NpcLabel; return _NpcLabel;
throw EParseException(NULL, toString("var_npc don't have a subpart '%s'", subPart.c_str()).c_str()); throw EParseException(NULL, toString("var_npc don't have a subpart '%s'", subPart.c_str()).c_str());
@ -137,7 +137,7 @@ public:
string evalVar(const string &subPart) string evalVar(const string &subPart)
{ {
if (subPart == "") if (subPart.empty())
return string("\"")+_NpcLabel+"\""; return string("\"")+_NpcLabel+"\"";
throw EParseException(NULL, toString("var_npc_name don't have a subpart '%s'", subPart.c_str()).c_str()); throw EParseException(NULL, toString("var_npc_name don't have a subpart '%s'", subPart.c_str()).c_str());

View file

@ -1069,7 +1069,7 @@ void GenerateSpecialItem( int numMP, const CSString& nomMP, const MPCraftStats&
void parseSpecialAttributes(const CSString &specialAttributes, MPCraftStats &craftStats, CExtraInfo &extraInfo) void parseSpecialAttributes(const CSString &specialAttributes, MPCraftStats &craftStats, CExtraInfo &extraInfo)
{ {
// evaluate DropOrSell according to CraftStats: can DropOrSell if it is a MP Craft // evaluate DropOrSell according to CraftStats: can DropOrSell if it is a MP Craft
extraInfo.DropOrSell= craftStats.Craft != ""; extraInfo.DropOrSell= !craftStats.Craft.empty();
// parse attributes // parse attributes
vector<string> strArray; vector<string> strArray;

View file

@ -254,7 +254,8 @@ int importCsv(const char *filename)
do do
{ {
fields.push_back(s.splitTo(';', true)); fields.push_back(s.splitTo(';', true));
} while (s != ""); }
while (!s.empty());
} }
// read values for each item // read values for each item
@ -278,7 +279,8 @@ int importCsv(const char *filename)
{ {
val = s.splitTo(';', true); val = s.splitTo(';', true);
items[n].push_back(val); items[n].push_back(val);
} while (s != ""); }
while (!s.empty());
} }
fclose(f); fclose(f);
@ -376,7 +378,7 @@ void updateItemField(CVectorSString &lines, uint itemIndex, uint fieldIndex, uin
if (pos == string::npos) if (pos == string::npos)
continue; continue;
if (val != "") if (!val.empty())
{ {
// check if the attribute is the right one and not included in another one // check if the attribute is the right one and not included in another one
// for example: Protection is in ProtectionFactor // for example: Protection is in ProtectionFactor
@ -507,7 +509,7 @@ int main(int argc, char *argv[])
} }
// create a .csv file // create a .csv file
if (scriptFile != "") if (!scriptFile.empty())
{ {
if (CFile::getFilename(scriptFile) == scriptFile) if (CFile::getFilename(scriptFile) == scriptFile)
scriptFile = curDir + scriptFile; scriptFile = curDir + scriptFile;
@ -545,7 +547,7 @@ int main(int argc, char *argv[])
} }
// create a .txt file // create a .txt file
if (csvFile != "") if (!csvFile.empty())
{ {
if (CFile::getFilename(csvFile) == csvFile) if (CFile::getFilename(csvFile) == csvFile)
csvFile = curDir + csvFile; csvFile = curDir + csvFile;

View file

@ -205,7 +205,7 @@ bool CExport::export_ (SExportOptions &options, IExportCB *expCB)
if (_ExportCB != NULL) if (_ExportCB != NULL)
_ExportCB->dispPass ("Loading height map"); _ExportCB->dispPass ("Loading height map");
_HeightMap = NULL; _HeightMap = NULL;
if (_Options->HeightMapFile != "") if (!_Options->HeightMapFile.empty())
{ {
_HeightMap = new CBitmap; _HeightMap = new CBitmap;
try try
@ -236,7 +236,7 @@ bool CExport::export_ (SExportOptions &options, IExportCB *expCB)
if (_ExportCB != NULL) if (_ExportCB != NULL)
_ExportCB->dispPass ("Loading height map"); _ExportCB->dispPass ("Loading height map");
_HeightMap2 = NULL; _HeightMap2 = NULL;
if (_Options->HeightMapFile2 != "") if (!_Options->HeightMapFile2.empty())
{ {
_HeightMap2 = new CBitmap; _HeightMap2 = new CBitmap;
try try
@ -267,7 +267,7 @@ bool CExport::export_ (SExportOptions &options, IExportCB *expCB)
if (_ExportCB != NULL) if (_ExportCB != NULL)
_ExportCB->dispPass ("Loading color map"); _ExportCB->dispPass ("Loading color map");
_ColorMap = NULL; _ColorMap = NULL;
if (_Options->ColorMapFile != "") if (!_Options->ColorMapFile.empty())
{ {
_ColorMap = new CBitmap; _ColorMap = new CBitmap;
try try
@ -314,12 +314,12 @@ bool CExport::export_ (SExportOptions &options, IExportCB *expCB)
try try
{ {
// Add zone files // Add zone files
if (_Options->OutZoneDir != "") if (!_Options->OutZoneDir.empty())
NLMISC::CPath::getPathContent(_Options->OutZoneDir, true, false, true, allFiles); NLMISC::CPath::getPathContent(_Options->OutZoneDir, true, false, true, allFiles);
// Add ig files // Add ig files
vector<string> allOtherFiles; vector<string> allOtherFiles;
if (_Options->OutIGDir != "") if (!_Options->OutIGDir.empty())
NLMISC::CPath::getPathContent(_Options->OutIGDir, true, false, true, allOtherFiles); NLMISC::CPath::getPathContent(_Options->OutIGDir, true, false, true, allOtherFiles);
allFiles.insert(allFiles.end(), allOtherFiles.begin(), allOtherFiles.end()); allFiles.insert(allFiles.end(), allOtherFiles.begin(), allOtherFiles.end());
} }
@ -386,7 +386,7 @@ bool CExport::export_ (SExportOptions &options, IExportCB *expCB)
_ZoneMaxX = nMaxX; _ZoneMaxX = nMaxX;
_ZoneMaxY = nMaxY; _ZoneMaxY = nMaxY;
if ((_Options->ZoneMin != "") && (_Options->ZoneMax != "")) if (!_Options->ZoneMin.empty() && !_Options->ZoneMax.empty())
{ {
_Options->ZoneMin = strupr (_Options->ZoneMin); _Options->ZoneMin = strupr (_Options->ZoneMin);
_Options->ZoneMax = strupr (_Options->ZoneMax); _Options->ZoneMax = strupr (_Options->ZoneMax);

View file

@ -51,7 +51,7 @@ int main(int argc, char **argv)
} }
} }
if (inputfile == "") if (inputfile.empty())
{ {
nlwarning("Error: missing input file(s)"); nlwarning("Error: missing input file(s)");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);

View file

@ -735,7 +735,7 @@ public:
return UserCodes[i].UserCode; return UserCodes[i].UserCode;
// then look for a default code // then look for a default code
for (i=0; i<UserCodes.size(); ++i) for (i=0; i<UserCodes.size(); ++i)
if (UserCodes[i].Event == name && UserCodes[i].CodeSpecializer == "") if (UserCodes[i].Event == name && UserCodes[i].CodeSpecializer.empty())
return UserCodes[i].UserCode; return UserCodes[i].UserCode;
return ""; return "";
} }

View file

@ -669,7 +669,7 @@ NLMISC_COMMAND(pacsBuildProximityMap,"build a set of proximity maps from a cwmap
// load the collision map file and generate our buffer from it // load the collision map file and generate our buffer from it
CProximityMapBuffer buffer; CProximityMapBuffer buffer;
string ext = CFile::getExtension(name); string ext = CFile::getExtension(name);
if (ext == "") if (ext.empty())
ext = "cwmap2"; ext = "cwmap2";
string fileName= OutputPath+CFile::getFilenameWithoutExtension(name)+"."+ext; string fileName= OutputPath+CFile::getFilenameWithoutExtension(name)+"."+ext;
nlinfo("Building proximity map: Loading cwmap2 file: %s",fileName.c_str()); nlinfo("Building proximity map: Loading cwmap2 file: %s",fileName.c_str());

View file

@ -83,21 +83,21 @@ sint main(sint argc, char **argv)
{ {
if (string(argv[i]) == string("-")) if (string(argv[i]) == string("-"))
{ {
if (cmd != "") if (!cmd.empty())
{ {
commands.push_back(cmd); commands.push_back(cmd);
cmd = ""; cmd.clear();
} }
} }
else else
{ {
if (cmd != "") if (!cmd.empty())
cmd += ' '; cmd += ' ';
cmd += argv[i]; cmd += argv[i];
} }
} }
if (cmd != "") if (!cmd.empty())
commands.push_back(cmd); commands.push_back(cmd);
NLMISC::createDebug (); NLMISC::createDebug ();

View file

@ -745,11 +745,11 @@ int extractBotNames(int argc, char *argv[])
// saving the modified files // saving the modified files
ucstring s = prepareExcelSheet(botNames); ucstring s = prepareExcelSheet(botNames);
CI18N::writeTextFile(workBotNamesFile.asString(), s, false); CI18N::writeTextFile(workBotNamesFile.asString(), s);
s = prepareExcelSheet(transBotNames); s = prepareExcelSheet(transBotNames);
CI18N::writeTextFile(transBotNamesFile.asString(), s, false); CI18N::writeTextFile(transBotNamesFile.asString(), s);
s = prepareExcelSheet(fcts); s = prepareExcelSheet(fcts);
CI18N::writeTextFile(workTitleFile.asString(), s, false); CI18N::writeTextFile(workTitleFile.asString(), s);
return 0; return 0;
} }

View file

@ -315,7 +315,7 @@ void extractNewWords(string workSheetFileName, string columnId, IWordListBuilder
ucstring s = prepareExcelSheet(workSheet); ucstring s = prepareExcelSheet(workSheet);
try try
{ {
CI18N::writeTextFile(workSheetFileName.c_str(), s, false); CI18N::writeTextFile(workSheetFileName.c_str(), s);
} }
catch (const Exception &e) catch (const Exception &e)
{ {

View file

@ -190,7 +190,7 @@ bool readPhraseFile1(const std::string &filename, vector<TPhrase> &phrases, bool
{ {
ucstring doc; ucstring doc;
CI18N::readTextFile(filename, doc, false, false, false, CI18N::LINE_FMT_CRLF); CI18N::readTextFile(filename, doc, false, false, false, CI18N::LINE_FMT_LF);
verifyVersion(doc, 1); verifyVersion(doc, 1);
return readPhraseFileFromString(doc, filename, phrases, forceRehash); return readPhraseFileFromString(doc, filename, phrases, forceRehash);
} }
@ -199,7 +199,7 @@ bool readPhraseFile2(const std::string &filename, vector<TPhrase> &phrases, bool
{ {
ucstring doc; ucstring doc;
CI18N::readTextFile(filename, doc, false, false, false, CI18N::LINE_FMT_CRLF); CI18N::readTextFile(filename, doc, false, false, false, CI18N::LINE_FMT_LF);
verifyVersion(doc, 2); verifyVersion(doc, 2);
return readPhraseFileFromString(doc, filename, phrases, forceRehash); return readPhraseFileFromString(doc, filename, phrases, forceRehash);
} }
@ -352,7 +352,7 @@ bool mergeStringDiff(vector<TStringInfo> &strings, const string &language, const
{ {
// Check if the diff is translated // Check if the diff is translated
ucstring text; ucstring text;
CI18N::readTextFile(diffs[i], text, false, false, false, CI18N::LINE_FMT_CRLF); CI18N::readTextFile(diffs[i], text, false, false, false, CI18N::LINE_FMT_LF);
if (text.find(ucstring("DIFF NOT TRANSLATED")) != ucstring::npos) if (text.find(ucstring("DIFF NOT TRANSLATED")) != ucstring::npos)
{ {
LOG("Diff file [%s] is not translated, merging it later.\n", CFile::getFilename(diffs[i]).c_str()); LOG("Diff file [%s] is not translated, merging it later.\n", CFile::getFilename(diffs[i]).c_str());
@ -679,7 +679,7 @@ void cleanComment(const std::string & filename)
ucstring text; ucstring text;
uint nbOldValue=0; uint nbOldValue=0;
CI18N::readTextFile(filename, text, false, false, false, CI18N::LINE_FMT_CRLF); CI18N::readTextFile(filename, text, false, false, false, CI18N::LINE_FMT_LF);
ucstring newText; ucstring newText;
ucstring::size_type last = 0; ucstring::size_type last = 0;
@ -703,7 +703,7 @@ void cleanComment(const std::string & filename)
} }
} }
text = newText; text = newText;
newText = ucstring(""); newText.clear();
last = 0; last = 0;
while ( last != ucstring::npos) while ( last != ucstring::npos)
{ {
@ -800,7 +800,7 @@ int mergeStringDiff(int argc, char *argv[])
{ {
// backup the original file // backup the original file
ucstring old; ucstring old;
CI18N::readTextFile(filename, old, false, true, false, CI18N::LINE_FMT_CRLF); CI18N::readTextFile(filename, old, false, true, false, CI18N::LINE_FMT_LF);
if (old != str) if (old != str)
CFile::moveFile(historyDir+CFile::getFilenameWithoutExtension(filename)+"_"+diffVersion+"."+CFile::getExtension(filename), filename); CFile::moveFile(historyDir+CFile::getFilenameWithoutExtension(filename)+"_"+diffVersion+"."+CFile::getExtension(filename), filename);
} }
@ -840,7 +840,7 @@ bool mergePhraseDiff(vector<TPhrase> &phrases, const string &language, bool only
{ {
// Check if the diff is translated // Check if the diff is translated
ucstring text; ucstring text;
CI18N::readTextFile(diffs[i], text, false, false, false, CI18N::LINE_FMT_CRLF); CI18N::readTextFile(diffs[i], text, false, false, false, CI18N::LINE_FMT_LF);
verifyVersion(text, 1); verifyVersion(text, 1);
if (text.find(ucstring("DIFF NOT TRANSLATED")) != ucstring::npos) if (text.find(ucstring("DIFF NOT TRANSLATED")) != ucstring::npos)
{ {
@ -1164,7 +1164,7 @@ int mergePhraseDiff(int argc, char *argv[], int version)
{ {
// backup the original file // backup the original file
ucstring old; ucstring old;
CI18N::readTextFile(filename, old, false, true, false, CI18N::LINE_FMT_CRLF); CI18N::readTextFile(filename, old, false, true, false, CI18N::LINE_FMT_LF);
if (old != str) if (old != str)
CFile::moveFile(historyDir+CFile::getFilenameWithoutExtension(filename)+"_"+diffVersion+"."+CFile::getExtension(filename), filename); CFile::moveFile(historyDir+CFile::getFilenameWithoutExtension(filename)+"_"+diffVersion+"."+CFile::getExtension(filename), filename);
} }
@ -1333,7 +1333,7 @@ int mergeClauseDiff(int argc, char *argv[])
{ {
// backup the original file // backup the original file
ucstring old; ucstring old;
CI18N::readTextFile(filename, old, false, true, false, CI18N::LINE_FMT_CRLF); CI18N::readTextFile(filename, old, false, true, false, CI18N::LINE_FMT_LF);
if (old != str) if (old != str)
CFile::moveFile(historyDir+CFile::getFilenameWithoutExtension(filename)+"_"+diffVersion+"."+CFile::getExtension(filename), filename); CFile::moveFile(historyDir+CFile::getFilenameWithoutExtension(filename)+"_"+diffVersion+"."+CFile::getExtension(filename), filename);
} }
@ -1358,7 +1358,7 @@ bool mergeWorksheetDiff(const std::string filename, TWorksheet &sheet, bool only
if (onlyTranslated) if (onlyTranslated)
{ {
ucstring text; ucstring text;
CI18N::readTextFile(fileList[i], text, false, false, false, CI18N::LINE_FMT_CRLF); CI18N::readTextFile(fileList[i], text, false, false, false, CI18N::LINE_FMT_LF);
if (text.find(ucstring("DIFF NOT TRANSLATED")) != ucstring::npos) if (text.find(ucstring("DIFF NOT TRANSLATED")) != ucstring::npos)
{ {
LOG("Diff file [%s] is not translated, merging it later.\n", CFile::getFilename(fileList[i]).c_str()); LOG("Diff file [%s] is not translated, merging it later.\n", CFile::getFilename(fileList[i]).c_str());
@ -1666,7 +1666,7 @@ int makeWorksheetDiff(int argc, char *argv[], const std::string &additionFilenam
string fn(CFile::getFilenameWithoutExtension(referenceFilename)), ext(CFile::getExtension(referenceFilename)); string fn(CFile::getFilenameWithoutExtension(referenceFilename)), ext(CFile::getExtension(referenceFilename));
std::string diffName(diffDir+fn+"_diff_"+diffVersion+"."+ext); std::string diffName(diffDir+fn+"_diff_"+diffVersion+"."+ext);
CI18N::writeTextFile(diffName, str, false); CI18N::writeTextFile(diffName, str);
} }
@ -1691,9 +1691,9 @@ int mergeWorksheetDiff(int argc, char *argv[], const std::string &filename, cons
// there is no translated file yet, build one from the working file. // there is no translated file yet, build one from the working file.
ucstring str; ucstring str;
string addfn = addDir+additionFile; string addfn = addDir+additionFile;
CI18N::readTextFile(addfn, str, false, false, false, CI18N::LINE_FMT_CRLF); CI18N::readTextFile(addfn, str, false, false, false, CI18N::LINE_FMT_LF);
str = str.substr(0, str.find(nl)+2); str = str.substr(0, str.find(nl)+2);
CI18N::writeTextFile(transDir+filename, str, false); CI18N::writeTextFile(transDir+filename, str);
// reread the file. // reread the file.
bool res = loadExcelSheet(transDir+filename, translated); bool res = loadExcelSheet(transDir+filename, translated);
nlassert(res); nlassert(res);
@ -1711,7 +1711,7 @@ int mergeWorksheetDiff(int argc, char *argv[], const std::string &filename, cons
{ {
// backup the original file // backup the original file
ucstring old; ucstring old;
CI18N::readTextFile(transDir+filename, old, false, true, false, CI18N::LINE_FMT_CRLF); CI18N::readTextFile(transDir+filename, old, false, true, false, CI18N::LINE_FMT_LF);
if (old != str) if (old != str)
{ {
string fn(CFile::getFilenameWithoutExtension(filename)), ext(CFile::getExtension(filename)); string fn(CFile::getFilenameWithoutExtension(filename)), ext(CFile::getExtension(filename));
@ -1720,7 +1720,7 @@ int mergeWorksheetDiff(int argc, char *argv[], const std::string &filename, cons
} }
if (translated.size() > 0) if (translated.size() > 0)
CI18N::writeTextFile(transDir+filename, str, false); CI18N::writeTextFile(transDir+filename, str);
return 0; return 0;
} }
@ -1865,7 +1865,7 @@ void cropLines(const std::string &filename, uint32 nbLines)
LOG("Cropping %u lines from file '%s'\n", nbLines, filename.c_str()); LOG("Cropping %u lines from file '%s'\n", nbLines, filename.c_str());
CI18N::readTextFile(filename, utext, false, false, false, CI18N::LINE_FMT_CRLF); CI18N::readTextFile(filename, utext, false, false, false, CI18N::LINE_FMT_LF);
string text = utext.toUtf8(); string text = utext.toUtf8();
@ -1881,7 +1881,7 @@ void cropLines(const std::string &filename, uint32 nbLines)
utext.fromUtf8(text); utext.fromUtf8(text);
CI18N::writeTextFile(filename, utext, true); CI18N::writeTextFile(filename, utext);
} }
@ -1910,7 +1910,7 @@ int makeWork()
// change #include "*_en.txt" into #include "*_wk.txt" // change #include "*_en.txt" into #include "*_wk.txt"
ucstring utext; ucstring utext;
CI18N::readTextFile(filename, utext, false, false, false, CI18N::LINE_FMT_CRLF); CI18N::readTextFile(filename, utext, false, false, false, CI18N::LINE_FMT_LF);
string text = utext.toUtf8(); string text = utext.toUtf8();
bool changedFile = false; bool changedFile = false;
@ -1943,7 +1943,7 @@ int makeWork()
if (changedFile) if (changedFile)
{ {
utext.fromUtf8(text); utext.fromUtf8(text);
CI18N::writeTextFile(filename, utext, true); CI18N::writeTextFile(filename, utext);
} }
// change filename // change filename
@ -2348,7 +2348,7 @@ void patchWorkFile(vector<TPhrase> &updatedPhrase, const std::string & filename)
{ {
ucstring text; ucstring text;
if ( updatedPhrase.empty() ) { return; } if ( updatedPhrase.empty() ) { return; }
CI18N::readTextFile(filename, text, false, false, false, CI18N::LINE_FMT_CRLF); CI18N::readTextFile(filename, text, false, false, false, CI18N::LINE_FMT_LF);
vector<TPhrase>::const_iterator first(updatedPhrase.begin()); vector<TPhrase>::const_iterator first(updatedPhrase.begin());
vector<TPhrase>::const_iterator last(updatedPhrase.end()); vector<TPhrase>::const_iterator last(updatedPhrase.end());
for (; first != last; ++first) for (; first != last; ++first)
@ -2489,7 +2489,7 @@ bool mergePhraseDiff2(vector<TPhrase> &phrases, const string &language, bool onl
{ {
// Check if the diff is translated // Check if the diff is translated
ucstring text; ucstring text;
CI18N::readTextFile(diffs[i], text, false, false, false, CI18N::LINE_FMT_CRLF); CI18N::readTextFile(diffs[i], text, false, false, false, CI18N::LINE_FMT_LF);
verifyVersion(text, 2); verifyVersion(text, 2);
if (text.find(ucstring("DIFF NOT TRANSLATED")) != ucstring::npos) if (text.find(ucstring("DIFF NOT TRANSLATED")) != ucstring::npos)
{ {
@ -2947,7 +2947,7 @@ void preprocessTextFile(const std::string &filename,
// Transform the string in ucstring according to format header // Transform the string in ucstring according to format header
if (!text.empty()) if (!text.empty())
CI18N::readTextBuffer((uint8*)&text[0], (uint)text.size(), result, false); CI18N::readTextBuffer((uint8*)&text[0], (uint)text.size(), result);
@ -3029,7 +3029,7 @@ int mergePhraseDiff(int argc, char *argv[])
{ {
// backup the original file // backup the original file
ucstring old; ucstring old;
CI18N::readTextFile(filename, old, false, true, false, CI18N::LINE_FMT_CRLF); CI18N::readTextFile(filename, old, false, true, false, CI18N::LINE_FMT_LF);
if (old != str) if (old != str)
CFile::moveFile((historyDir+CFile::getFilenameWithoutExtension(filename)+"_"+diffVersion+"."+CFile::getExtension(filename)).c_str(), filename.c_str()); CFile::moveFile((historyDir+CFile::getFilenameWithoutExtension(filename)+"_"+diffVersion+"."+CFile::getExtension(filename)).c_str(), filename.c_str());
} }