From 13670eefeb4b256c20b603a845eb89f5221a32e5 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 10 Sep 2011 15:48:22 +0300 Subject: Change empty strings initializations. --- src/being.cpp | 2 +- src/commandhandler.cpp | 4 +-- src/configuration.cpp | 2 +- src/gui/chatwindow.cpp | 2 +- src/gui/logindialog.cpp | 4 +-- src/gui/minimap.cpp | 2 +- src/gui/npcdialog.cpp | 4 +-- src/gui/setup_video.cpp | 2 +- src/gui/widgets/chattab.cpp | 2 +- src/map.cpp | 2 +- src/net/ea/gui/guildtab.cpp | 2 +- src/net/ea/partyhandler.cpp | 2 +- src/net/manaserv/charhandler.cpp | 4 +-- src/net/manaserv/generalhandler.cpp | 2 +- src/resources/iteminfo.cpp | 2 +- src/resources/spritedef.h | 2 +- src/spellmanager.cpp | 4 +-- src/textcommand.cpp | 62 ++++++++++++++++++------------------- src/utils/sha256.cpp | 2 +- src/utils/stringutils.cpp | 4 +-- 20 files changed, 55 insertions(+), 57 deletions(-) (limited to 'src') diff --git a/src/being.cpp b/src/being.cpp index 883bde321..da83f1f73 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -1277,7 +1277,7 @@ void Being::logic() case ATTACK: { - std::string particleEffect = ""; + std::string particleEffect(""); if (!mActionTime) break; diff --git a/src/commandhandler.cpp b/src/commandhandler.cpp index d16a7db27..5de5eb2cf 100644 --- a/src/commandhandler.cpp +++ b/src/commandhandler.cpp @@ -355,8 +355,8 @@ void CommandHandler::handleWho(const std::string &args A_UNUSED, void CommandHandler::handleMsg(const std::string &args, ChatTab *tab) { - std::string recvnick = ""; - std::string msg = ""; + std::string recvnick(""); + std::string msg(""); if (args.substr(0, 1) == "\"") { diff --git a/src/configuration.cpp b/src/configuration.cpp index a6ef27815..94c0dce37 100644 --- a/src/configuration.cpp +++ b/src/configuration.cpp @@ -262,7 +262,7 @@ int Configuration::resetIntValue(const std::string &key) std::string Configuration::getStringValue(const std::string &key) const { GETLOG(); - std::string defaultValue = ""; + std::string defaultValue(""); Options::const_iterator iter = mOptions.find(key); if (iter == mOptions.end()) { diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp index f3e4b88b8..2bada256c 100644 --- a/src/gui/chatwindow.cpp +++ b/src/gui/chatwindow.cpp @@ -1074,7 +1074,7 @@ std::string ChatWindow::addColors(std::string &msg) return msg; } - std::string newMsg = ""; + std::string newMsg(""); int cMap[] = {1, 4, 5, 2, 3, 6, 7, 9, 0, 8}; // rainbow diff --git a/src/gui/logindialog.cpp b/src/gui/logindialog.cpp index adf499f75..26248059c 100644 --- a/src/gui/logindialog.cpp +++ b/src/gui/logindialog.cpp @@ -50,8 +50,8 @@ static const int LOGIN_DIALOG_WIDTH = 300; static const int LOGIN_DIALOG_HEIGHT = 140; static const int FIELD_WIDTH = LOGIN_DIALOG_WIDTH - 70; -std::string LoginDialog::savedPassword = ""; -std::string LoginDialog::savedPasswordKey = ""; +std::string LoginDialog::savedPassword(""); +std::string LoginDialog::savedPasswordKey(""); const char *UPDATE_TYPE_TEXT[3] = diff --git a/src/gui/minimap.cpp b/src/gui/minimap.cpp index a16da2b65..70bbc1dad 100644 --- a/src/gui/minimap.cpp +++ b/src/gui/minimap.cpp @@ -89,7 +89,7 @@ Minimap::~Minimap() void Minimap::setMap(Map *map) { - std::string caption = ""; + std::string caption(""); std::string minimapName; if (map) diff --git a/src/gui/npcdialog.cpp b/src/gui/npcdialog.cpp index d941153b7..3956b47ac 100644 --- a/src/gui/npcdialog.cpp +++ b/src/gui/npcdialog.cpp @@ -228,8 +228,8 @@ void NpcDialog::action(const gcn::ActionEvent &event) } else if (mActionState == NPC_ACTION_INPUT) { - std::string printText = ""; // Text that will get printed - // in the textbox + std::string printText(""); // Text that will get printed + // in the textbox if (mInputState == NPC_INPUT_LIST) { diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp index e9811a920..d3c1163dc 100644 --- a/src/gui/setup_video.cpp +++ b/src/gui/setup_video.cpp @@ -179,7 +179,7 @@ void ModeListModel::addCustomMode(std::string mode) int ModeListModel::getIndexOf(const std::string &widthXHeightMode) { - std::string currentMode = ""; + std::string currentMode(""); for (int i = 0; i < getNumberOfElements(); i++) { currentMode = getElementAt(i); diff --git a/src/gui/widgets/chattab.cpp b/src/gui/widgets/chattab.cpp index 4f358c8e7..485e96e74 100644 --- a/src/gui/widgets/chattab.cpp +++ b/src/gui/widgets/chattab.cpp @@ -337,7 +337,7 @@ void ChatTab::chatInput(const std::string &message) start = msg.find('[', start + 1); } - std::string temp = ""; + std::string temp(""); if (start + 1 < msg.length() && end < msg.length() && end > start + 1) { diff --git a/src/map.cpp b/src/map.cpp index 86d1171f0..3e83f2e6c 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -2217,7 +2217,7 @@ MapItem::~MapItem() void MapItem::setType(int type) { - std::string name = ""; + std::string name(""); mType = type; if (mImage) mImage->decRef(); diff --git a/src/net/ea/gui/guildtab.cpp b/src/net/ea/gui/guildtab.cpp index ab030be83..9836f5fa9 100644 --- a/src/net/ea/gui/guildtab.cpp +++ b/src/net/ea/gui/guildtab.cpp @@ -101,7 +101,7 @@ bool GuildTab::handleCommand(const std::string &type, const std::string &args) else if (type == "notice" && taGuild) { std::string str1 = args.substr(0, 60); - std::string str2 = ""; + std::string str2(""); if (args.size() > 60) str2 = args.substr(60); Net::getGuildHandler()->changeNotice(taGuild->getId(), str1, str2); diff --git a/src/net/ea/partyhandler.cpp b/src/net/ea/partyhandler.cpp index bd6f19d97..e006b9c71 100644 --- a/src/net/ea/partyhandler.cpp +++ b/src/net/ea/partyhandler.cpp @@ -203,7 +203,7 @@ void PartyHandler::processPartyInvited(Net::MessageIn &msg) { int id = msg.readInt32(); std::string partyName = msg.readString(24); - std::string nick = ""; + std::string nick(""); Being *being; if (actorSpriteManager) diff --git a/src/net/manaserv/charhandler.cpp b/src/net/manaserv/charhandler.cpp index 3b2306feb..42db6e621 100644 --- a/src/net/manaserv/charhandler.cpp +++ b/src/net/manaserv/charhandler.cpp @@ -138,7 +138,7 @@ void CharHandler::handleCharacterCreateResponse(Net::MessageIn &msg) if (errMsg != ERRMSG_OK) { // Character creation failed - std::string errorMessage = ""; + std::string errorMessage(""); switch (errMsg) { case ERRMSG_NO_LOGIN: @@ -212,7 +212,7 @@ void CharHandler::handleCharacterDeleteResponse(Net::MessageIn &msg) else { // Character deletion failed - std::string errorMessage = ""; + std::string errorMessage(""); switch (errMsg) { case ERRMSG_NO_LOGIN: diff --git a/src/net/manaserv/generalhandler.cpp b/src/net/manaserv/generalhandler.cpp index 9e32f139d..2eea6cdf6 100644 --- a/src/net/manaserv/generalhandler.cpp +++ b/src/net/manaserv/generalhandler.cpp @@ -64,7 +64,7 @@ namespace ManaServ Connection *accountServerConnection = 0; Connection *chatServerConnection = 0; Connection *gameServerConnection = 0; -std::string netToken = ""; +std::string netToken(""); ServerInfo gameServer; ServerInfo chatServer; diff --git a/src/resources/iteminfo.cpp b/src/resources/iteminfo.cpp index 75e6e1d8c..a5b81081c 100644 --- a/src/resources/iteminfo.cpp +++ b/src/resources/iteminfo.cpp @@ -108,7 +108,7 @@ const std::string &ItemInfo::getSprite(Gender gender) const } else { - static const std::string empty = ""; + static const std::string empty(""); std::map::const_iterator i = mAnimationFiles.find(gender); diff --git a/src/resources/spritedef.h b/src/resources/spritedef.h index ccad62b1b..b2939fca1 100644 --- a/src/resources/spritedef.h +++ b/src/resources/spritedef.h @@ -86,7 +86,7 @@ namespace SpriteAction static const std::string CAST_MAGIC = "magic"; static const std::string USE_ITEM = "item"; static const std::string SPAWN = "spawn"; - static const std::string INVALID = ""; + static const std::string INVALID(""); } enum SpriteDirection diff --git a/src/spellmanager.cpp b/src/spellmanager.cpp index fcdf94039..9f777f9e4 100644 --- a/src/spellmanager.cpp +++ b/src/spellmanager.cpp @@ -184,8 +184,8 @@ std::string SpellManager::parseCommand(std::string command, if (!player_node) return command; - std::string name = ""; - std::string id = ""; + std::string name(""); + std::string id(""); std::string name2; if (target) diff --git a/src/textcommand.cpp b/src/textcommand.cpp index 665668c7e..33dff85aa 100644 --- a/src/textcommand.cpp +++ b/src/textcommand.cpp @@ -35,18 +35,18 @@ TextCommand::TextCommand(unsigned int id, std::string symbol, std::string icon, unsigned int basicLvl, MagicSchool school, unsigned int schoolLvl, int mana) : + mCommand(command), + mSymbol(symbol), + mTargetType(type), + mIcon(icon), + mId(id), + mMana(mana), + mSchool(school), + mBaseLvl(basicLvl), + mSchoolLvl(schoolLvl), + mCommandType(TEXT_COMMAND_MAGIC), mImage(0) { - mId = id; - mCommand = command; - mSymbol = symbol; - mTargetType = type; - mIcon = icon; - mBaseLvl = basicLvl; - mSchool = school; - mSchoolLvl = schoolLvl; - mMana = mana; - mCommandType = TEXT_COMMAND_MAGIC; loadImage(); } @@ -54,36 +54,34 @@ TextCommand::TextCommand(unsigned int id, std::string symbol, TextCommand::TextCommand(unsigned int id, std::string symbol, std::string command, SpellTarget type, std::string icon) : + mCommand(command), + mSymbol(symbol), + mTargetType(type), + mIcon(icon), + mId(id), + mMana(0), + mSchool(SKILL_MAGIC), + mBaseLvl(0), + mSchoolLvl(0), + mCommandType(TEXT_COMMAND_TEXT), mImage(0) { - mId = id; - mCommand = command; - mSymbol = symbol; - mTargetType = type; - mIcon = icon; - mCommandType = TEXT_COMMAND_TEXT; - mBaseLvl = 0; - mSchool = SKILL_MAGIC; - mSchoolLvl = 0; - mMana = 0; - mCommandType = TEXT_COMMAND_TEXT; loadImage(); } TextCommand::TextCommand(unsigned int id) : + mCommand(""), + mSymbol(""), + mTargetType(NOTARGET), + mIcon(""), + mId(id), + mMana(0), + mSchool(SKILL_MAGIC), + mBaseLvl(0), + mSchoolLvl(0), + mCommandType(TEXT_COMMAND_TEXT), mImage(0) { - mId = id; - mCommand = ""; - mSymbol = ""; - mTargetType = NOTARGET; - mIcon = ""; - mCommandType = TEXT_COMMAND_TEXT; - mBaseLvl = 0; - mSchool = SKILL_MAGIC; - mSchoolLvl = 0; - mMana = 0; - mCommandType = TEXT_COMMAND_TEXT; loadImage(); } diff --git a/src/utils/sha256.cpp b/src/utils/sha256.cpp index 5d3e4c1d2..1e7143300 100644 --- a/src/utils/sha256.cpp +++ b/src/utils/sha256.cpp @@ -283,7 +283,7 @@ std::string SHA256Hash(const char *src, int len) SHA256Final(&ctx, bytehash); // Convert it to hex const char* hxc = "0123456789abcdef"; - std::string hash = ""; + std::string hash(""); for (int i = 0; i < SHA256_DIGEST_SIZE; i++) { hash += hxc[bytehash[i] / 16]; diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp index efe5f9efb..6c50d4019 100644 --- a/src/utils/stringutils.cpp +++ b/src/utils/stringutils.cpp @@ -465,7 +465,7 @@ std::string combineDye2(std::string file, std::string dye) if (pos != std::string::npos) { std::string dye1 = file.substr(pos + 1); - std::string str = ""; + std::string str(""); file = file.substr(0, pos); std::list list1 = splitToStringList(dye1, ';'); std::list list2 = splitToStringList(dye, ';'); @@ -505,7 +505,7 @@ std::vector getLang() std::string packList(std::list &list) { std::list::const_iterator i = list.begin(); - std::string str = ""; + std::string str(""); while (i != list.end()) { str = str + (*i) + "|"; -- cgit v1.2.3-70-g09d2