summaryrefslogtreecommitdiffstats
path: root/src/account-server
diff options
context:
space:
mode:
authorYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2011-08-11 02:54:10 +0200
committerYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2011-08-11 02:54:10 +0200
commit9527d079307454178fea3b2958e301875cecc15a (patch)
tree333ed71036813c9cdec4c8e1de1e058b86275bca /src/account-server
parent0820d6632b0ce5887c49d16929ac7903aa185fe4 (diff)
parent8766149dc12d197205b1632ec6e9fc663de05990 (diff)
downloadmanaserv-9527d079307454178fea3b2958e301875cecc15a.tar.gz
manaserv-9527d079307454178fea3b2958e301875cecc15a.tar.xz
manaserv-9527d079307454178fea3b2958e301875cecc15a.zip
Merge branch 'master' of git://gitorious.org/~bertram/mana/manaserv-equipment-fix into equipment-fix
Conflicts: src/common/manaserv_protocol.h
Diffstat (limited to 'src/account-server')
-rw-r--r--src/account-server/storage.cpp42
1 files changed, 27 insertions, 15 deletions
diff --git a/src/account-server/storage.cpp b/src/account-server/storage.cpp
index 9660120..05f8ec6 100644
--- a/src/account-server/storage.cpp
+++ b/src/account-server/storage.cpp
@@ -490,17 +490,26 @@ Character *Storage::getCharacterBySQL(Account *owner)
try
{
std::ostringstream sql;
- sql << " select slot_type, inventory_slot from "
+ sql << " select slot_type, item_id, item_instance from "
<< CHAR_EQUIPS_TBL_NAME
<< " where owner_id = '"
<< character->getDatabaseID() << "' order by slot_type desc;";
+ EquipData equipData;
const dal::RecordSet &equipInfo = mDb->execSql(sql.str());
if (!equipInfo.isEmpty())
+ {
+ EquipmentItem equipItem;
for (int k = 0, size = equipInfo.rows(); k < size; ++k)
- poss.equipSlots.insert(std::pair<unsigned int, unsigned int>(
- toUint(equipInfo(k, 0)),
- toUint(equipInfo(k, 1))));
+ {
+ equipItem.itemId = toUint(equipInfo(k, 1));
+ equipItem.itemInstance = toUint(equipInfo(k, 2));
+ equipData.insert(std::pair<unsigned int, EquipmentItem>(
+ toUint(equipInfo(k, 0)),
+ equipItem));
+ }
+ }
+ poss.setEquipment(equipData);
}
catch (const dal::DbSqlQueryExecFailure &e)
{
@@ -515,6 +524,7 @@ Character *Storage::getCharacterBySQL(Account *owner)
<< " where owner_id = '"
<< character->getDatabaseID() << "' order by slot asc;";
+ InventoryData inventoryData;
const dal::RecordSet &itemInfo = mDb->execSql(sql.str());
if (!itemInfo.isEmpty())
{
@@ -524,9 +534,10 @@ Character *Storage::getCharacterBySQL(Account *owner)
unsigned short slot = toUint(itemInfo(k, 2));
item.itemId = toUint(itemInfo(k, 3));
item.amount = toUint(itemInfo(k, 4));
- poss.inventory[slot] = item;
+ inventoryData[slot] = item;
}
}
+ poss.setInventory(inventoryData);
}
catch (const dal::DbSqlQueryExecFailure &e)
{
@@ -798,18 +809,18 @@ bool Storage::updateCharacter(Character *character)
std::ostringstream sql;
sql << "insert into " << CHAR_EQUIPS_TBL_NAME
- << " (owner_id, slot_type, inventory_slot) values ("
+ << " (owner_id, slot_type, item_id, item_instance) values ("
<< character->getDatabaseID() << ", ";
std::string base = sql.str();
const Possessions &poss = character->getPossessions();
- for (EquipData::const_iterator it = poss.equipSlots.begin(),
- it_end = poss.equipSlots.end();
- it != it_end;
- ++it)
+ const EquipData &equipData = poss.getEquipment();
+ for (EquipData::const_iterator it = equipData.begin(),
+ it_end = equipData.end(); it != it_end; ++it)
{
sql.str("");
- sql << base << it->first << ", " << it->second << ");";
+ sql << base << it->first << ", " << it->second.itemId
+ << ", " << it->second.itemInstance << ");";
mDb->execSql(sql.str());
}
@@ -820,13 +831,14 @@ bool Storage::updateCharacter(Character *character)
<< character->getDatabaseID() << ", ";
base = sql.str();
- for (InventoryData::const_iterator j = poss.inventory.begin(),
- j_end = poss.inventory.end(); j != j_end; ++j)
+ const InventoryData &inventoryData = poss.getInventory();
+ for (InventoryData::const_iterator j = inventoryData.begin(),
+ j_end = inventoryData.end(); j != j_end; ++j)
{
sql.str("");
unsigned short slot = j->first;
- unsigned int itemId = j->second.itemId;
- unsigned int amount = j->second.amount;
+ unsigned int itemId = j->second.itemId;
+ unsigned int amount = j->second.amount;
assert(itemId);
sql << base << slot << ", " << itemId << ", " << amount << ");";
mDb->execSql(sql.str());