- more code cleanup based on suggestions from cppcheck

This commit is contained in:
Mark Vejvoda 2012-10-18 08:16:47 +00:00
parent 829a72db35
commit e86cb3aeff
16 changed files with 63 additions and 56 deletions

View File

@ -585,7 +585,7 @@ string Game::extractFactionLogoFile(bool &loadingImageUsed, string factionName,
string linkedCurrentPath = techTreePath + "factions/" + factionName; string linkedCurrentPath = techTreePath + "factions/" + factionName;
endPathWithSlash(linkedCurrentPath); endPathWithSlash(linkedCurrentPath);
string linkedTmppath= linkedCurrentPath + factionName +".xml"; //string linkedTmppath= linkedCurrentPath + factionName +".xml";
path = linkedCurrentPath; path = linkedCurrentPath;
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] possible loading screen dir '%s'\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,path.c_str()); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] possible loading screen dir '%s'\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,path.c_str());

View File

@ -445,11 +445,11 @@ void ScriptManager::init(World* world, GameCamera *gameCamera, const XmlNode *ro
} }
} }
catch(const megaglest_runtime_error &ex) { catch(const megaglest_runtime_error &ex) {
string sErrBuf = ""; //string sErrBuf = "";
//if(ex.wantStackTrace() == true) { //if(ex.wantStackTrace() == true) {
char szErrBuf[8096]=""; char szErrBuf[8096]="";
sprintf(szErrBuf,"In [%s::%s %d]",__FILE__,__FUNCTION__,__LINE__); sprintf(szErrBuf,"In [%s::%s %d]",__FILE__,__FUNCTION__,__LINE__);
sErrBuf = string(szErrBuf) + string("\nerror [") + string(ex.what()) + string("]\n"); string sErrBuf = string(szErrBuf) + string("\nerror [") + string(ex.what()) + string("]\n");
//} //}
SystemFlags::OutputDebug(SystemFlags::debugError,sErrBuf.c_str()); SystemFlags::OutputDebug(SystemFlags::debugError,sErrBuf.c_str());
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,sErrBuf.c_str()); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,sErrBuf.c_str());

View File

@ -197,7 +197,6 @@ void Selection::addUnitToGroup(int groupIndex,Unit *unit) {
} }
if(unit != NULL) { if(unit != NULL) {
const UnitContainer &addUnits = selectedUnits;
groups[groupIndex].push_back(unit); groups[groupIndex].push_back(unit);
} }
} }

View File

@ -724,7 +724,6 @@ void MenuStateOptions::reloadUI() {
labelNetworkSettings.setText(lang.get("Network")); labelNetworkSettings.setText(lang.get("Network"));
labelServerPortLabel.setText(lang.get("ServerPort")); labelServerPortLabel.setText(lang.get("ServerPort"));
Config &config= Config::getInstance();
labelPublishServerExternalPort.setText(lang.get("PublishServerExternalPort")); labelPublishServerExternalPort.setText(lang.get("PublishServerExternalPort"));

View File

@ -229,7 +229,7 @@ vector<char> replaceAllBetweenTokens(vector<char>& context, const string &startT
string replaceAllBetweenTokens(string& context, const string &startToken, const string &endToken, const string &newText, bool removeTokens=true); string replaceAllBetweenTokens(string& context, const string &startToken, const string &endToken, const string &newText, bool removeTokens=true);
bool removeFile(string file); bool removeFile(string file);
bool renameFile(string oldFile, string newFile); bool renameFile(string oldFile, string newFile);
void removeFolder(const string path); void removeFolder(const string &path);
off_t getFileSize(string filename); off_t getFileSize(string filename);
bool searchAndReplaceTextInFile(string fileName, string findText, string replaceText, bool simulateOnly); bool searchAndReplaceTextInFile(string fileName, string findText, string replaceText, bool simulateOnly);
void copyFileTo(string fromFileName, string toFileName); void copyFileTo(string fromFileName, string toFileName);

View File

@ -94,7 +94,7 @@ LONG WINAPI UnhandledExceptionFilter2(struct _EXCEPTION_POINTERS *ExceptionInfo)
// Misc // Misc
// ===================================================== // =====================================================
LPWSTR Ansi2WideString(LPCSTR lpaszString); LPWSTR Ansi2WideString(LPCSTR lpaszString);
std::string utf8_encode(const std::wstring wstr); std::string utf8_encode(const std::wstring &wstr);
std::wstring utf8_decode(const std::string &str); std::wstring utf8_decode(const std::string &str);
std::string getRegKey(const std::string& location, const std::string& name); std::string getRegKey(const std::string& location, const std::string& name);

View File

@ -183,9 +183,8 @@ ftpSession_S* ftpGetSession(int id)
LOCAL int normalizePath(char* path) LOCAL int normalizePath(char* path)
{ {
char *in; char *in;
char *r = NULL; char *r = path;
r = path;
in = path; in = path;
while((in = strchr(in, '/'))) while((in = strchr(in, '/')))

View File

@ -224,10 +224,10 @@ float TextFreetypeGL::LineHeight(const char* str, const int len) {
//Font::scaleFontValueCenterHFactor = 30.0; //Font::scaleFontValueCenterHFactor = 30.0;
//Font::scaleFontValue = 1.0; //Font::scaleFontValue = 1.0;
float result = 0; //float result = 0;
//result = font->height - font->linegap; //result = font->height - font->linegap;
result = font->ascender - font->descender - font->linegap; float result = font->ascender - font->descender - font->linegap;
//printf("#2 LineHeight [%s] height = %f linegap = %f ascender = %f descender = %f\n",str,font->height,font->linegap,font->ascender,font->descender); //printf("#2 LineHeight [%s] height = %f linegap = %f ascender = %f descender = %f\n",str,font->height,font->linegap,font->ascender,font->descender);
//result += (result * Font::scaleFontValue); //result += (result * Font::scaleFontValue);
@ -260,9 +260,9 @@ float TextFreetypeGL::LineHeight(const char* str, const int len) {
float TextFreetypeGL::LineHeight(const wchar_t* str, const int len) { float TextFreetypeGL::LineHeight(const wchar_t* str, const int len) {
//Font::scaleFontValueCenterHFactor = 2.0; //Font::scaleFontValueCenterHFactor = 2.0;
float result = 0; //float result = 0;
result = font->height - font->linegap; float result = font->height - font->linegap;
// if(wcslen(str) > 0) { // if(wcslen(str) > 0) {
// TextureGlyph *glyph = texture_font_get_glyph( font, str[0] ); // TextureGlyph *glyph = texture_font_get_glyph( font, str[0] );

View File

@ -1134,11 +1134,11 @@ void BaseColorPickEntity::init(int bufferSize) {
} }
string BaseColorPickEntity::getColorDescription() const { string BaseColorPickEntity::getColorDescription() const {
string result = ""; //string result = "";
char szBuf[100]=""; char szBuf[100]="";
//sprintf(szBuf,"%d.%d.%d.%d",uniqueColorID[0],uniqueColorID[1],uniqueColorID[2],uniqueColorID[3]); //sprintf(szBuf,"%d.%d.%d.%d",uniqueColorID[0],uniqueColorID[1],uniqueColorID[2],uniqueColorID[3]);
sprintf(szBuf,"%d.%d.%d",uniqueColorID[0],uniqueColorID[1],uniqueColorID[2]); sprintf(szBuf,"%d.%d.%d",uniqueColorID[0],uniqueColorID[1],uniqueColorID[2]);
result = szBuf; string result = szBuf;
return result; return result;
} }

View File

@ -977,11 +977,11 @@ string LuaArguments::getStackText() const {
} }
else if(lua_istable(luaState, -i)){ else if(lua_istable(luaState, -i)){
int tableLen = 0; //int tableLen = 0;
#if LUA_VERSION_NUM > 501 #if LUA_VERSION_NUM > 501
tableLen = lua_rawlen(luaState, -i); int tableLen = lua_rawlen(luaState, -i);
#else #else
tableLen = luaL_getn(luaState, -i); int tableLen = luaL_getn(luaState, -i);
#endif #endif
stackString+= "Table (" + intToStr(tableLen) + ")\n"; stackString+= "Table (" + intToStr(tableLen) + ")\n";
// for(unsigned int j = 1; j < tableLen; ++j) { // for(unsigned int j = 1; j < tableLen; ++j) {

View File

@ -88,11 +88,11 @@ void BaseThread::setThreadOwnerValid(bool value) {
} }
bool BaseThread::getThreadOwnerValid() { bool BaseThread::getThreadOwnerValid() {
bool ret = false; //bool ret = false;
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__); static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
MutexSafeWrapper safeMutex(&mutexThreadOwnerValid,mutexOwnerId); MutexSafeWrapper safeMutex(&mutexThreadOwnerValid,mutexOwnerId);
//mutexThreadOwnerValid.setOwnerId(mutexOwnerId); //mutexThreadOwnerValid.setOwnerId(mutexOwnerId);
ret = threadOwnerValid; bool ret = threadOwnerValid;
safeMutex.ReleaseLock(); safeMutex.ReleaseLock();
return ret; return ret;
@ -115,22 +115,22 @@ void BaseThread::setQuitStatus(bool value) {
} }
bool BaseThread::getQuitStatus() { bool BaseThread::getQuitStatus() {
bool retval = false; //bool retval = false;
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__); static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
MutexSafeWrapper safeMutex(&mutexQuit,mutexOwnerId); MutexSafeWrapper safeMutex(&mutexQuit,mutexOwnerId);
//mutexQuit.setOwnerId(mutexOwnerId); //mutexQuit.setOwnerId(mutexOwnerId);
retval = quit; bool retval = quit;
safeMutex.ReleaseLock(); safeMutex.ReleaseLock();
return retval; return retval;
} }
bool BaseThread::getHasBeginExecution() { bool BaseThread::getHasBeginExecution() {
bool retval = false; //bool retval = false;
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__); static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
MutexSafeWrapper safeMutex(&mutexBeginExecution,mutexOwnerId); MutexSafeWrapper safeMutex(&mutexBeginExecution,mutexOwnerId);
//mutexBeginExecution.setOwnerId(mutexOwnerId); //mutexBeginExecution.setOwnerId(mutexOwnerId);
retval = hasBeginExecution; bool retval = hasBeginExecution;
safeMutex.ReleaseLock(); safeMutex.ReleaseLock();
return retval; return retval;
@ -149,11 +149,11 @@ void BaseThread::setHasBeginExecution(bool value) {
} }
bool BaseThread::getRunningStatus() { bool BaseThread::getRunningStatus() {
bool retval = false; //bool retval = false;
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__); static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
MutexSafeWrapper safeMutex(&mutexRunning,mutexOwnerId); MutexSafeWrapper safeMutex(&mutexRunning,mutexOwnerId);
retval = running; bool retval = running;
safeMutex.ReleaseLock(); safeMutex.ReleaseLock();
if(retval == false) { if(retval == false) {
@ -183,20 +183,20 @@ void BaseThread::setExecutingTask(bool value) {
} }
bool BaseThread::getExecutingTask() { bool BaseThread::getExecutingTask() {
bool retval = false; //bool retval = false;
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__); static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
MutexSafeWrapper safeMutex(&mutexExecutingTask,mutexOwnerId); MutexSafeWrapper safeMutex(&mutexExecutingTask,mutexOwnerId);
retval = executingTask; bool retval = executingTask;
safeMutex.ReleaseLock(); safeMutex.ReleaseLock();
return retval; return retval;
} }
bool BaseThread::getDeleteSelfOnExecutionDone() { bool BaseThread::getDeleteSelfOnExecutionDone() {
bool retval = false; //bool retval = false;
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__); static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
MutexSafeWrapper safeMutex(&mutexDeleteSelfOnExecutionDone,mutexOwnerId); MutexSafeWrapper safeMutex(&mutexDeleteSelfOnExecutionDone,mutexOwnerId);
retval = deleteSelfOnExecutionDone; bool retval = deleteSelfOnExecutionDone;
safeMutex.ReleaseLock(); safeMutex.ReleaseLock();
return retval; return retval;

View File

@ -443,7 +443,7 @@ bool fileExists(const string &path) {
return false; return false;
} }
void removeFolder(const string path) { void removeFolder(const string &path) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] path [%s]\n",__FILE__,__FUNCTION__,__LINE__,path.c_str()); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] path [%s]\n",__FILE__,__FUNCTION__,__LINE__,path.c_str());
string deletePath = path; string deletePath = path;
@ -1433,9 +1433,15 @@ void getFullscreenVideoInfo(int &colorBits,int &screenWidth,int &screenHeight,bo
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
/* Get available fullscreen/hardware modes */ /* Get available fullscreen/hardware modes */
int flags = SDL_RESIZABLE;
#if defined(WIN32) || defined(__APPLE__) #if defined(WIN32) || defined(__APPLE__)
flags = 0;
int flags = 0;
#else
int flags = SDL_RESIZABLE;
#endif #endif
if(isFullscreen) flags = SDL_FULLSCREEN; if(isFullscreen) flags = SDL_FULLSCREEN;
SDL_Rect**modes = SDL_ListModes(NULL, SDL_OPENGL|flags); SDL_Rect**modes = SDL_ListModes(NULL, SDL_OPENGL|flags);
@ -1528,9 +1534,15 @@ void getFullscreenVideoModes(vector<ModeInfo> *modeinfos, bool isFullscreen) {
/* Get available fullscreen/hardware modes */ /* Get available fullscreen/hardware modes */
//SDL_Rect**modes = SDL_ListModes(NULL, SDL_OPENGL|SDL_RESIZABLE); //SDL_Rect**modes = SDL_ListModes(NULL, SDL_OPENGL|SDL_RESIZABLE);
int flags = SDL_RESIZABLE;
#if defined(WIN32) || defined(__APPLE__) #if defined(WIN32) || defined(__APPLE__)
flags = 0;
int flags = 0;
#else
int flags = SDL_RESIZABLE;
#endif #endif
if(isFullscreen) flags = SDL_FULLSCREEN; if(isFullscreen) flags = SDL_FULLSCREEN;
SDL_Rect**modes = SDL_ListModes(&format, SDL_OPENGL|flags); SDL_Rect**modes = SDL_ListModes(&format, SDL_OPENGL|flags);

View File

@ -389,12 +389,12 @@ void SimpleTaskThread::setOverrideShutdownTask(taskFunctionCallback *ptr) {
} }
bool SimpleTaskThread::isThreadExecutionLagging() { bool SimpleTaskThread::isThreadExecutionLagging() {
bool result = false; //bool result = false;
//static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__); //static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__); string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
MutexSafeWrapper safeMutex(&mutexLastExecuteTimestamp,mutexOwnerId); MutexSafeWrapper safeMutex(&mutexLastExecuteTimestamp,mutexOwnerId);
mutexLastExecuteTimestamp.setOwnerId(mutexOwnerId); mutexLastExecuteTimestamp.setOwnerId(mutexOwnerId);
result = (difftime(time(NULL),lastExecuteTimestamp) >= 5.0); bool result = (difftime(time(NULL),lastExecuteTimestamp) >= 5.0);
safeMutex.ReleaseLock(); safeMutex.ReleaseLock();
return result; return result;
@ -507,12 +507,12 @@ void SimpleTaskThread::setTaskSignalled(bool value) {
} }
bool SimpleTaskThread::getTaskSignalled() { bool SimpleTaskThread::getTaskSignalled() {
bool retval = false; //bool retval = false;
//static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__); //static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__); string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
MutexSafeWrapper safeMutex(&mutexTaskSignaller,mutexOwnerId); MutexSafeWrapper safeMutex(&mutexTaskSignaller,mutexOwnerId);
mutexTaskSignaller.setOwnerId(mutexOwnerId); mutexTaskSignaller.setOwnerId(mutexOwnerId);
retval = taskSignalled; bool retval = taskSignalled;
safeMutex.ReleaseLock(); safeMutex.ReleaseLock();
return retval; return retval;

View File

@ -2592,15 +2592,15 @@ bool UPNP_Tools::upnp_add_redirect(int ports[2],bool mutexLock) {
sprintf(ext_port_str, "%d", ports[0]); sprintf(ext_port_str, "%d", ports[0]);
sprintf(int_port_str, "%d", ports[1]); sprintf(int_port_str, "%d", ports[1]);
int r = 0; //int r = 0;
#ifndef MINIUPNPC_VERSION_PRE1_5 #ifndef MINIUPNPC_VERSION_PRE1_5
#ifndef MINIUPNPC_VERSION_PRE1_6 #ifndef MINIUPNPC_VERSION_PRE1_6
r = UPNP_AddPortMapping(urls.controlURL, data.first.servicetype,ext_port_str, int_port_str, lanaddr, "MegaGlest - www.megaglest.org", "TCP", 0, NULL); int r = UPNP_AddPortMapping(urls.controlURL, data.first.servicetype,ext_port_str, int_port_str, lanaddr, "MegaGlest - www.megaglest.org", "TCP", 0, NULL);
#else #else
r = UPNP_AddPortMapping(urls.controlURL, data.first.servicetype,ext_port_str, int_port_str, lanaddr, "MegaGlest - www.megaglest.org", "TCP", 0); int r = UPNP_AddPortMapping(urls.controlURL, data.first.servicetype,ext_port_str, int_port_str, lanaddr, "MegaGlest - www.megaglest.org", "TCP", 0);
#endif #endif
#else #else
r = UPNP_AddPortMapping(urls.controlURL, data.servicetype,ext_port_str, int_port_str, lanaddr, "MegaGlest - www.megaglest.org", "TCP", 0); int r = UPNP_AddPortMapping(urls.controlURL, data.servicetype,ext_port_str, int_port_str, lanaddr, "MegaGlest - www.megaglest.org", "TCP", 0);
#endif #endif
if (r != UPNPCOMMAND_SUCCESS) { if (r != UPNPCOMMAND_SUCCESS) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] AddPortMapping(%s, %s, %s) failed\n",__FILE__,__FUNCTION__,__LINE__,ext_port_str, int_port_str, lanaddr); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] AddPortMapping(%s, %s, %s) failed\n",__FILE__,__FUNCTION__,__LINE__,ext_port_str, int_port_str, lanaddr);

View File

@ -54,7 +54,7 @@ LPWSTR Ansi2WideString(LPCSTR lpaszString) {
} }
// Convert a wide Unicode string to an UTF8 string // Convert a wide Unicode string to an UTF8 string
std::string utf8_encode(const std::wstring wstr) { std::string utf8_encode(const std::wstring &wstr) {
int size_needed = WideCharToMultiByte(CP_UTF8, 0, &wstr[0], (int)wstr.size(), NULL, 0, NULL, NULL); int size_needed = WideCharToMultiByte(CP_UTF8, 0, &wstr[0], (int)wstr.size(), NULL, 0, NULL, NULL);
std::string strTo( size_needed, 0 ); std::string strTo( size_needed, 0 );
WideCharToMultiByte(CP_UTF8, 0, &wstr[0], (int)wstr.size(), &strTo[0], size_needed, NULL, NULL); WideCharToMultiByte(CP_UTF8, 0, &wstr[0], (int)wstr.size(), &strTo[0], size_needed, NULL, NULL);

View File

@ -167,11 +167,10 @@ std::map<string,string> Properties::getTagReplacementValues(std::map<string,stri
// #1 // #1
// First add the standard tags // First add the standard tags
// //
char *homeDir = NULL;
#ifdef WIN32 #ifdef WIN32
homeDir = getenv("USERPROFILE"); char *homeDir = getenv("USERPROFILE");
#else #else
homeDir = getenv("HOME"); char *homeDir = getenv("HOME");
#endif #endif
mapTagReplacementValues["~/"] = (homeDir != NULL ? homeDir : ""); mapTagReplacementValues["~/"] = (homeDir != NULL ? homeDir : "");
@ -204,8 +203,8 @@ std::map<string,string> Properties::getTagReplacementValues(std::map<string,stri
} }
#endif #endif
char *username = NULL; //char *username = NULL;
username = getenv("USERNAME"); char *username = getenv("USERNAME");
mapTagReplacementValues["$USERNAME"] = (username != NULL ? username : ""); mapTagReplacementValues["$USERNAME"] = (username != NULL ? username : "");
mapTagReplacementValues["%%USERNAME%%"] = (username != NULL ? username : ""); mapTagReplacementValues["%%USERNAME%%"] = (username != NULL ? username : "");
@ -257,11 +256,10 @@ bool Properties::applyTagsToValue(string &value, std::map<string,string> *mapTag
} }
} }
else { else {
char *homeDir = NULL;
#ifdef WIN32 #ifdef WIN32
homeDir = getenv("USERPROFILE"); char *homeDir = getenv("USERPROFILE");
#else #else
homeDir = getenv("HOME"); char *homeDir = getenv("HOME");
#endif #endif
replaceAll(value, "~/", (homeDir != NULL ? homeDir : "")); replaceAll(value, "~/", (homeDir != NULL ? homeDir : ""));
@ -293,8 +291,8 @@ bool Properties::applyTagsToValue(string &value, std::map<string,string> *mapTag
} }
#endif #endif
char *username = NULL; //char *username = NULL;
username = getenv("USERNAME"); char *username = getenv("USERNAME");
replaceAll(value, "$USERNAME", (username != NULL ? username : "")); replaceAll(value, "$USERNAME", (username != NULL ? username : ""));
replaceAll(value, "%%USERNAME%%", (username != NULL ? username : "")); replaceAll(value, "%%USERNAME%%", (username != NULL ? username : ""));
replaceAll(value, "{USERNAME}", (username != NULL ? username : "")); replaceAll(value, "{USERNAME}", (username != NULL ? username : ""));