diff options
author | Erik Schilling <ablu.erikschilling@googlemail.com> | 2012-02-28 07:08:27 +0100 |
---|---|---|
committer | Erik Schilling <ablu.erikschilling@googlemail.com> | 2012-02-28 16:48:35 +0100 |
commit | 9b2445c45608e55e91ee32453dff2163d958f7e2 (patch) | |
tree | 322a1f0584a66298968b22e0c59655b0c3403a98 /src/account-server | |
parent | b966735fae77a62fbd366936840c089455d21af0 (diff) | |
download | manaserv-9b2445c45608e55e91ee32453dff2163d958f7e2.tar.gz manaserv-9b2445c45608e55e91ee32453dff2163d958f7e2.tar.bz2 manaserv-9b2445c45608e55e91ee32453dff2163d958f7e2.tar.xz manaserv-9b2445c45608e55e91ee32453dff2163d958f7e2.zip |
Removed unnessecary second check for same condition
Reviewed-by: Bertram.
Diffstat (limited to 'src/account-server')
-rw-r--r-- | src/account-server/storage.cpp | 127 |
1 files changed, 62 insertions, 65 deletions
diff --git a/src/account-server/storage.cpp b/src/account-server/storage.cpp index 370819ca..ea3cee39 100644 --- a/src/account-server/storage.cpp +++ b/src/account-server/storage.cpp @@ -2087,84 +2087,81 @@ void Storage::syncDatabase() if (!xmlStrEqual(node->name, BAD_CAST "item")) continue; - if (xmlStrEqual(node->name, BAD_CAST "item")) - { - int id = XML::getProperty(node, "id", 0); + int id = XML::getProperty(node, "id", 0); - if (id < 1) - continue; + if (id < 1) + continue; - int weight = XML::getProperty(node, "weight", 0); - std::string type = XML::getProperty(node, "type", std::string()); - std::string name = XML::getProperty(node, "name", std::string()); - std::string desc = XML::getProperty(node, "description", - std::string()); - std::string eff = XML::getProperty(node, "effect", std::string()); - std::string image = XML::getProperty(node, "image", std::string()); - std::string dye; + int weight = XML::getProperty(node, "weight", 0); + std::string type = XML::getProperty(node, "type", std::string()); + std::string name = XML::getProperty(node, "name", std::string()); + std::string desc = XML::getProperty(node, "description", + std::string()); + std::string eff = XML::getProperty(node, "effect", std::string()); + std::string image = XML::getProperty(node, "image", std::string()); + std::string dye; + + // Split image name and dye string + size_t pipe = image.find("|"); + if (pipe != std::string::npos) + { + dye = image.substr(pipe + 1); + image = image.substr(0, pipe); + } - // Split image name and dye string - size_t pipe = image.find("|"); - if (pipe != std::string::npos) - { - dye = image.substr(pipe + 1); - image = image.substr(0, pipe); - } + try + { + std::ostringstream sql; + sql << "UPDATE " << ITEMS_TBL_NAME + << " SET name = ?, " + << " description = ?, " + << " image = '" << image << "', " + << " weight = " << weight << ", " + << " itemtype = '" << type << "', " + << " effect = ?, " + << " dyestring = '" << dye << "' " + << " WHERE id = " << id; - try + if (mDb->prepareSql(sql.str())) { - std::ostringstream sql; - sql << "UPDATE " << ITEMS_TBL_NAME - << " SET name = ?, " - << " description = ?, " - << " image = '" << image << "', " - << " weight = " << weight << ", " - << " itemtype = '" << type << "', " - << " effect = ?, " - << " dyestring = '" << dye << "' " - << " WHERE id = " << id; - - if (mDb->prepareSql(sql.str())) - { - mDb->bindValue(1, name); - mDb->bindValue(2, desc); - mDb->bindValue(3, eff); + mDb->bindValue(1, name); + mDb->bindValue(2, desc); + mDb->bindValue(3, eff); - mDb->processSql(); - if (mDb->getModifiedRows() == 0) + mDb->processSql(); + if (mDb->getModifiedRows() == 0) + { + sql.clear(); + sql.str(""); + sql << "INSERT INTO " << ITEMS_TBL_NAME + << " VALUES ( " << id << ", ?, ?, '" + << image << "', " << weight << ", '" + << type << "', ?, '" << dye << "' )"; + if (mDb->prepareSql(sql.str())) { - sql.clear(); - sql.str(""); - sql << "INSERT INTO " << ITEMS_TBL_NAME - << " VALUES ( " << id << ", ?, ?, '" - << image << "', " << weight << ", '" - << type << "', ?, '" << dye << "' )"; - if (mDb->prepareSql(sql.str())) - { - mDb->bindValue(1, name); - mDb->bindValue(2, desc); - mDb->bindValue(3, eff); - mDb->processSql(); - } - else - { - utils::throwError("(DALStorage::SyncDatabase) " - "SQL query preparation failure #2."); - } + mDb->bindValue(1, name); + mDb->bindValue(2, desc); + mDb->bindValue(3, eff); + mDb->processSql(); + } + else + { + utils::throwError("(DALStorage::SyncDatabase) " + "SQL query preparation failure #2."); } } - else - { - utils::throwError("(DALStorage::SyncDatabase) " - "SQL query preparation failure #1."); - } - itemCount++; } - catch (const dal::DbSqlQueryExecFailure &e) + else { utils::throwError("(DALStorage::SyncDatabase) " - "SQL query failure: ", e); + "SQL query preparation failure #1."); } + itemCount++; + } + catch (const dal::DbSqlQueryExecFailure &e) + { + utils::throwError("(DALStorage::SyncDatabase) " + "SQL query failure: ", e); } } |