summaryrefslogtreecommitdiff
path: root/src/account-server/storage.cpp
diff options
context:
space:
mode:
authorFreeyorp <Freeyorp101@hotmail.com>2010-08-29 19:47:25 +1200
committerFreeyorp <Freeyorp101@hotmail.com>2010-08-29 19:47:25 +1200
commit7fc50c2d31e1d289e9d2a950271c6d399fe0896a (patch)
tree1ebff71f7b1526425cc57e2e3b2681297e540f90 /src/account-server/storage.cpp
parent853cbb6efdb79f879fabc2133acb8c11d9d4f7b1 (diff)
parent7db9f6fe36b737d2eec7c6070497035b0834def2 (diff)
downloadmanaserv-7fc50c2d31e1d289e9d2a950271c6d399fe0896a.tar.gz
manaserv-7fc50c2d31e1d289e9d2a950271c6d399fe0896a.tar.bz2
manaserv-7fc50c2d31e1d289e9d2a950271c6d399fe0896a.tar.xz
manaserv-7fc50c2d31e1d289e9d2a950271c6d399fe0896a.zip
Merge branch 'testing'
Conflicts: src/account-server/storage.cpp src/game-server/being.cpp src/game-server/being.hpp src/game-server/character.cpp src/game-server/character.hpp src/game-server/gamehandler.cpp src/game-server/inventory.cpp src/scripting/lua.cpp src/sql/mysql/createTables.sql src/sql/sqlite/createTables.sql
Diffstat (limited to 'src/account-server/storage.cpp')
-rw-r--r--src/account-server/storage.cpp371
1 files changed, 222 insertions, 149 deletions
diff --git a/src/account-server/storage.cpp b/src/account-server/storage.cpp
index 4f43ed53..323bc587 100644
--- a/src/account-server/storage.cpp
+++ b/src/account-server/storage.cpp
@@ -39,7 +39,7 @@ static const char *DEFAULT_ITEM_FILE = "items.xml";
// defines the supported db version
static const char *DB_VERSION_PARAMETER = "database_version";
-static const char *SUPPORTED_DB_VERSION = "10";
+static const char *SUPPORTED_DB_VERSION = "11";
/*
* MySQL specificities:
@@ -66,24 +66,26 @@ static const char *SUPPORTED_DB_VERSION = "10";
* TODO: Fix problem with PostgreSQL null primary key's.
*/
-static const char *ACCOUNTS_TBL_NAME = "mana_accounts";
-static const char *CHARACTERS_TBL_NAME = "mana_characters";
-static const char *CHAR_SKILLS_TBL_NAME = "mana_char_skills";
-static const char *CHAR_STATUS_EFFECTS_TBL_NAME = "mana_char_status_effects";
-static const char *CHAR_KILL_COUNT_TBL_NAME = "mana_char_kill_stats";
-static const char *CHAR_SPECIALS_TBL_NAME = "mana_char_specials";
-static const char *INVENTORIES_TBL_NAME = "mana_inventories";
-static const char *ITEMS_TBL_NAME = "mana_items";
-static const char *GUILDS_TBL_NAME = "mana_guilds";
-static const char *GUILD_MEMBERS_TBL_NAME = "mana_guild_members";
-static const char *QUESTS_TBL_NAME = "mana_quests";
-static const char *WORLD_STATES_TBL_NAME = "mana_world_states";
-static const char *POST_TBL_NAME = "mana_post";
-static const char *POST_ATTACHMENTS_TBL_NAME = "mana_post_attachments";
-static const char *AUCTION_TBL_NAME = "mana_auctions";
-static const char *AUCTION_BIDS_TBL_NAME = "mana_auction_bids";
-static const char *ONLINE_USERS_TBL_NAME = "mana_online_list";
-static const char *TRANSACTION_TBL_NAME = "mana_transactions";
+static const char *ACCOUNTS_TBL_NAME = "mana_accounts";
+static const char *CHARACTERS_TBL_NAME = "mana_characters";
+static const char *CHAR_ATTR_TBL_NAME = "mana_char_attr";
+static const char *CHAR_SKILLS_TBL_NAME = "mana_char_skills";
+static const char *CHAR_STATUS_EFFECTS_TBL_NAME = "mana_char_status_effects";
+static const char *CHAR_KILL_COUNT_TBL_NAME = "mana_char_kill_stats";
+static const char *CHAR_SPECIALS_TBL_NAME = "mana_char_specials";
+static const char *CHAR_EQUIPS_TBL_NAME = "mana_char_equips";
+static const char *INVENTORIES_TBL_NAME = "mana_inventories";
+static const char *ITEMS_TBL_NAME = "mana_items";
+static const char *GUILDS_TBL_NAME = "mana_guilds";
+static const char *GUILD_MEMBERS_TBL_NAME = "mana_guild_members";
+static const char *QUESTS_TBL_NAME = "mana_quests";
+static const char *WORLD_STATES_TBL_NAME = "mana_world_states";
+static const char *POST_TBL_NAME = "mana_post";
+static const char *POST_ATTACHMENTS_TBL_NAME = "mana_post_attachments";
+static const char *AUCTION_TBL_NAME = "mana_auctions";
+static const char *AUCTION_BIDS_TBL_NAME = "mana_auction_bids";
+static const char *ONLINE_USERS_TBL_NAME = "mana_online_list";
+static const char *TRANSACTION_TBL_NAME = "mana_transactions";
/**
* Constructor.
@@ -169,7 +171,7 @@ Account *Storage::getAccountBySQL()
// we have no choice but to return nothing.
if (accountInfo.isEmpty())
{
- return NULL;
+ return 0;
}
// specialize the string_to functor to convert
@@ -189,7 +191,7 @@ Account *Storage::getAccountBySQL()
int level = toUint(accountInfo(0, 4));
// Check if the user is permanently banned, or temporarily banned.
if (level == AL_BANNED
- || time(NULL) <= (int) toUint(accountInfo(0, 5)))
+ || time(0) <= (int) toUint(accountInfo(0, 5)))
{
account->setLevel(AL_BANNED);
// It is, so skip character loading.
@@ -237,7 +239,7 @@ Account *Storage::getAccountBySQL()
catch (const dal::DbSqlQueryExecFailure &e)
{
LOG_ERROR("DALStorage::getAccountBySQL: " << e.what());
- return NULL; // TODO: Throw exception here
+ return 0; // TODO: Throw exception here
}
}
@@ -297,13 +299,12 @@ Character *Storage::getCharacterBySQL(Account *owner)
// if the character is not even in the database then
// we have no choice but to return nothing.
if (charInfo.isEmpty())
- {
- return NULL;
- }
+ return 0;
// specialize the string_to functor to convert
// a string to an unsigned short.
string_to< unsigned short > toUshort;
+ string_to< double > toDouble;
character = new Character(charInfo(0, 2), toUint(charInfo(0, 0)));
character->setGender(toUshort(charInfo(0, 3)));
@@ -312,16 +313,10 @@ Character *Storage::getCharacterBySQL(Account *owner)
character->setLevel(toUshort(charInfo(0, 6)));
character->setCharacterPoints(toUshort(charInfo(0, 7)));
character->setCorrectionPoints(toUshort(charInfo(0, 8)));
- character->getPossessions().money = toUint(charInfo(0, 9));
- Point pos(toUshort(charInfo(0, 10)), toUshort(charInfo(0, 11)));
+ Point pos(toUshort(charInfo(0, 9)), toUshort(charInfo(0, 10)));
character->setPosition(pos);
- for (int i = 0; i < CHAR_ATTR_NB; ++i)
- {
- character->setAttribute(CHAR_ATTR_BEGIN + i,
- toUshort(charInfo(0, 13 + i)));
- }
- int mapId = toUint(charInfo(0, 12));
+ int mapId = toUint(charInfo(0, 11));
if (mapId > 0)
{
character->setMapId(mapId);
@@ -350,12 +345,35 @@ Character *Storage::getCharacterBySQL(Account *owner)
character->setAccountLevel(toUint(levelInfo(0, 0)), true);
}
- // load the skills of the char from CHAR_SKILLS_TBL_NAME
std::ostringstream s;
- s << "SELECT skill_id, skill_exp "
- << "FROM " << CHAR_SKILLS_TBL_NAME << " "
+
+ /*
+ * Load attributes.
+ */
+ s << "SELECT attr_id, attr_base, attr_mod "
+ << "FROM " << CHAR_ATTR_TBL_NAME << " "
<< "WHERE char_id = " << character->getDatabaseID();
+ const dal::RecordSet &attrInfo = mDb->execSql(s.str());
+ if (!attrInfo.isEmpty())
+ {
+ const unsigned int nRows = attrInfo.rows();
+ for (unsigned int row = 0; row < nRows; ++row)
+ {
+ unsigned int id = toUint(attrInfo(row, 0));
+ character->setAttribute(id, toDouble(attrInfo(row, 1)));
+ character->setModAttribute(id, toDouble(attrInfo(row, 2)));
+ }
+ }
+
+ s.clear();
+ s.str("");
+
+ // load the skills of the char from CHAR_SKILLS_TBL_NAME
+
+ s << "select status_id, status_time FROM " << CHAR_STATUS_EFFECTS_TBL_NAME
+ << " WHERE char_id = " << character->getDatabaseID();
+
const dal::RecordSet &skillInfo = mDb->execSql(s.str());
if (!skillInfo.isEmpty())
{
@@ -417,7 +435,28 @@ Character *Storage::getCharacterBySQL(Account *owner)
catch (const dal::DbSqlQueryExecFailure &e)
{
LOG_ERROR("(DALStorage::getCharacter #1) SQL query failure: " << e.what());
- return NULL;
+ return 0;
+ }
+
+ Possessions &poss = character->getPossessions();
+
+ try
+ {
+ std::ostringstream sql;
+ sql << " select * from " << CHAR_EQUIPS_TBL_NAME << " where owner_id = '"
+ << character->getDatabaseID() << "' order by slot_type desc;";
+
+ const dal::RecordSet &equipInfo = mDb->execSql(sql.str());
+ if (!equipInfo.isEmpty())
+ for (int k = 0, size = equipInfo.rows(); k < size; ++k)
+ poss.equipSlots.insert(std::pair<unsigned int, unsigned int>(
+ toUint(equipInfo(k, 3)),
+ toUint(equipInfo(k, 2))));
+ }
+ catch (const dal::DbSqlQueryExecFailure &e)
+ {
+ LOG_ERROR("(DALStorage::getCharacter #1) SQL query failure: " << e.what());
+ return 0;
}
try
@@ -428,44 +467,19 @@ Character *Storage::getCharacterBySQL(Account *owner)
const dal::RecordSet &itemInfo = mDb->execSql(sql.str());
if (!itemInfo.isEmpty())
- {
- Possessions &poss = character->getPossessions();
- unsigned nextSlot = 0;
-
for (int k = 0, size = itemInfo.rows(); k < size; ++k)
{
- unsigned slot = toUint(itemInfo(k, 2));
- if (slot < EQUIPMENT_SLOTS)
- {
- poss.equipment[slot] = toUint(itemInfo(k, 3));
- }
- else
- {
- slot -= 32;
- if (slot >= INVENTORY_SLOTS || slot < nextSlot)
- {
- LOG_ERROR("(DALStorage::getCharacter #2) Corrupted inventory.");
- break;
- }
- InventoryItem item;
- if (slot != nextSlot)
- {
- item.itemId = 0;
- item.amount = slot - nextSlot;
- poss.inventory.push_back(item);
- }
- item.itemId = toUint(itemInfo(k, 3));
- item.amount = toUint(itemInfo(k, 4));
- poss.inventory.push_back(item);
- nextSlot = slot + 1;
- }
+ InventoryItem item;
+ unsigned short slot = toUint(itemInfo(k, 2));
+ item.itemId = toUint(itemInfo(k, 3));
+ item.amount = toUint(itemInfo(k, 4));
+ poss.inventory[slot] = item;
}
- }
}
catch (const dal::DbSqlQueryExecFailure &e)
{
LOG_ERROR("(DALStorage::getCharacter #2) SQL query failure: " << e.what());
- return NULL;
+ return 0;
}
return character;
@@ -505,7 +519,7 @@ Character *Storage::getCharacter(const std::string &name)
{
mDb->bindValue(1, name);
}
- return getCharacterBySQL(NULL);
+ return getCharacterBySQL(0);
}
/**
@@ -623,16 +637,9 @@ bool Storage::updateCharacter(Character *character,
<< "level = '" << character->getLevel() << "', "
<< "char_pts = '" << character->getCharacterPoints() << "', "
<< "correct_pts = '"<< character->getCorrectionPoints() << "', "
- << "money = '" << character->getPossessions().money << "', "
<< "x = '" << character->getPosition().x << "', "
<< "y = '" << character->getPosition().y << "', "
- << "map_id = '" << character->getMapId() << "', "
- << "str = '" << character->getAttribute(CHAR_ATTR_STRENGTH) << "', "
- << "agi = '" << character->getAttribute(CHAR_ATTR_AGILITY) << "', "
- << "dex = '" << character->getAttribute(CHAR_ATTR_DEXTERITY) << "', "
- << "vit = '" << character->getAttribute(CHAR_ATTR_VITALITY) << "', "
- << "`int` = '" << character->getAttribute(CHAR_ATTR_INTELLIGENCE) << "', "
- << "will = '" << character->getAttribute(CHAR_ATTR_WILLPOWER) << "' "
+ << "map_id = '" << character->getMapId() << "' "
<< "where id = '" << character->getDatabaseID() << "';";
mDb->execSql(sqlUpdateCharacterInfo.str());
@@ -649,13 +656,34 @@ bool Storage::updateCharacter(Character *character,
}
/**
+ * Character attributes.
+ */
+ try
+ {
+ std::ostringstream sqlAttr;
+ for (AttributeMap::const_iterator
+ it = character->mAttributes.begin(),
+ it_end = character->mAttributes.end();
+ it != it_end;
+ ++it)
+ updateAttribute(character->getDatabaseID(), it->first,
+ it->second.first, it->second.second);
+ }
+ catch (const dal::DbSqlQueryExecFailure &e)
+ {
+ if (startTransaction)
+ mDb->rollbackTransaction();
+ LOG_ERROR("(DALStorage::updateCharacter #2) SQL query failure: " << e.what());
+ }
+
+ /**
* Character's skills
*/
try
{
std::map<int, int>::const_iterator skill_it;
- for (skill_it = character->getSkillBegin();
- skill_it != character->getSkillEnd(); skill_it++)
+ for (skill_it = character->mExperience.begin();
+ skill_it != character->mExperience.end(); skill_it++)
{
updateExperience(character->getDatabaseID(), skill_it->first, skill_it->second);
}
@@ -667,7 +695,7 @@ bool Storage::updateCharacter(Character *character,
{
mDb->rollbackTransaction();
}
- LOG_ERROR("(DALStorage::updateCharacter #2) SQL query failure: " << e.what());
+ LOG_ERROR("(DALStorage::updateCharacter #3) SQL query failure: " << e.what());
return false;
}
@@ -690,7 +718,7 @@ bool Storage::updateCharacter(Character *character,
{
mDb->rollbackTransaction();
}
- LOG_ERROR("(DALStorage::updateCharacter #3) SQL query failure: " << e.what());
+ LOG_ERROR("(DALStorage::updateCharacter #4) SQL query failure: " << e.what());
return false;
}
/**
@@ -724,7 +752,7 @@ bool Storage::updateCharacter(Character *character,
{
mDb->rollbackTransaction();
}
- LOG_ERROR("(DALStorage::updateCharacter #4) SQL query failure: " << e.what());
+ LOG_ERROR("(DALStorage::updateCharacter #5) SQL query failure: " << e.what());
return false;
}
@@ -757,36 +785,39 @@ bool Storage::updateCharacter(Character *character,
{
std::ostringstream sql;
- sql << "insert into " << INVENTORIES_TBL_NAME
- << " (owner_id, slot, class_id, amount) values ("
+ sql << "insert into " << CHAR_EQUIPS_TBL_NAME
+ << " (owner_id, slot_type, inventory_slot) values ("
<< character->getDatabaseID() << ", ";
std::string base = sql.str();
const Possessions &poss = character->getPossessions();
-
- for (int j = 0; j < EQUIPMENT_SLOTS; ++j)
+ for (EquipData::const_iterator it = poss.equipSlots.begin(),
+ it_end = poss.equipSlots.end();
+ it != it_end;
+ ++it)
{
- int v = poss.equipment[j];
- if (!v) continue;
- sql.str(std::string());
- sql << base << j << ", " << v << ", 1);";
- mDb->execSql(sql.str());
+ sql.str("");
+ sql << base << it->first << ", " << it->second << ");";
+ mDb->execSql(sql.str());
}
- int slot = 32;
- for (std::vector< InventoryItem >::const_iterator j = poss.inventory.begin(),
+ sql.str("");
+
+ sql << "insert into " << INVENTORIES_TBL_NAME
+ << " (owner_id, slot, class_id, amount) values ("
+ << character->getDatabaseID() << ", ";
+ base = sql.str();
+
+ for (InventoryData::const_iterator j = poss.inventory.begin(),
j_end = poss.inventory.end(); j != j_end; ++j)
{
- int v = j->itemId;
- if (!v)
- {
- slot += j->amount;
- continue;
- }
- sql.str(std::string());
- sql << base << slot << ", " << v << ", " << unsigned(j->amount) << ");";
+ sql.str("");
+ unsigned short slot = j->first;
+ unsigned int itemId = j->second.itemId;
+ unsigned int amount = j->second.amount;
+ assert(itemId);
+ sql << base << slot << ", " << itemId << ", " << amount << ");";
mDb->execSql(sql.str());
- ++slot;
}
}
@@ -797,7 +828,7 @@ bool Storage::updateCharacter(Character *character,
{
mDb->rollbackTransaction();
}
- LOG_ERROR("(DALStorage::updateCharacter #4) SQL query failure: " << e.what());
+ LOG_ERROR("(DALStorage::updateCharacter #6) SQL query failure: " << e.what());
return false;
}
@@ -821,7 +852,7 @@ bool Storage::updateCharacter(Character *character,
{
mDb->rollbackTransaction();
}
- LOG_ERROR("(DALStorage::updateCharacter #5) SQL query failure: " << e.what());
+ LOG_ERROR("(DALStorage::updateCharacter #7) SQL query failure: " << e.what());
return false;
}
try
@@ -840,7 +871,7 @@ bool Storage::updateCharacter(Character *character,
{
mDb->rollbackTransaction();
}
- LOG_ERROR("(DALStorage::updateCharacter #6) SQL query failure: " << e.what());
+ LOG_ERROR("(DALStorage::updateCharacter #8) SQL query failure: " << e.what());
return false;
}
if (startTransaction)
@@ -952,8 +983,8 @@ void Storage::flush(Account *account)
// uniqueness
sqlInsertCharactersTable
<< "insert into " << CHARACTERS_TBL_NAME
- << " (user_id, name, gender, hair_style, hair_color, level, char_pts, correct_pts, money,"
- << " x, y, map_id, str, agi, dex, vit, `int`, will ) values ("
+ << " (user_id, name, gender, hair_style, hair_color, level, char_pts, correct_pts,"
+ << " x, y, map_id) values ("
<< account->getID() << ", \""
<< (*it)->getName() << "\", "
<< (*it)->getGender() << ", "
@@ -962,16 +993,9 @@ void Storage::flush(Account *account)
<< (int)(*it)->getLevel() << ", "
<< (int)(*it)->getCharacterPoints() << ", "
<< (int)(*it)->getCorrectionPoints() << ", "
- << (*it)->getPossessions().money << ", "
<< (*it)->getPosition().x << ", "
<< (*it)->getPosition().y << ", "
- << (*it)->getMapId() << ", "
- << (*it)->getAttribute(CHAR_ATTR_STRENGTH) << ", "
- << (*it)->getAttribute(CHAR_ATTR_AGILITY) << ", "
- << (*it)->getAttribute(CHAR_ATTR_DEXTERITY) << ", "
- << (*it)->getAttribute(CHAR_ATTR_VITALITY) << ", "
- << (*it)->getAttribute(CHAR_ATTR_INTELLIGENCE) << ", "
- << (*it)->getAttribute(CHAR_ATTR_WILLPOWER) << " "
+ << (*it)->getMapId()
<< ");";
mDb->execSql(sqlInsertCharactersTable.str());
@@ -979,13 +1003,23 @@ void Storage::flush(Account *account)
// Update the character ID.
(*it)->setDatabaseID(mDb->getLastId());
+ // Update all attributes.
+ std::map<unsigned int, std::pair<double, double> >::const_iterator
+ attr_it, attr_end;
+ for (attr_it = (*it)->mAttributes.begin(),
+ attr_end = (*it)->mAttributes.end();
+ attr_it != attr_end;
+ ++attr_it)
+ updateAttribute((*it)->getDatabaseID(), attr_it->first,
+ attr_it->second.first,
+ attr_it->second.second);
+
// update the characters skill
std::map<int, int>::const_iterator skill_it;
- for (skill_it = (*it)->getSkillBegin();
- skill_it != (*it)->getSkillEnd(); skill_it++)
- {
+ for (skill_it = (*it)->mExperience.begin();
+ skill_it != (*it)->mExperience.end();
+ skill_it++)
updateExperience((*it)->getDatabaseID(), skill_it->first, skill_it->second);
- }
}
} //
@@ -1076,31 +1110,26 @@ void Storage::updateLastLogin(const Account *account)
* @param CharId ID of the character
* @param CharPoints Number of character points left for the character
* @param CorrPoints Number of correction points left for the character
- * @param AttribId ID of the modified attribute
- * @param AttribValue New value of the modified attribute
*/
void Storage::updateCharacterPoints(int charId,
- int charPoints, int corrPoints,
- int attribId, int attribValue)
+ int charPoints, int corrPoints)
{
- std::ostringstream sql;
- sql << "UPDATE " << CHARACTERS_TBL_NAME
- << " SET char_pts = " << charPoints << ", "
- << " correct_pts = " << corrPoints << ", ";
+ try
+ {
+ std::ostringstream sql;
+ sql << "UPDATE " << CHARACTERS_TBL_NAME
+ << " SET char_pts = " << charPoints << ", "
+ << " correct_pts = " << corrPoints << ", "
+ << " WHERE id = " << charId;
- switch (attribId)
+ mDb->execSql(sql.str());
+ }
+ catch (dal::DbSqlQueryExecFailure &e)
{
- case CHAR_ATTR_STRENGTH: sql << "`str` = "; break;
- case CHAR_ATTR_AGILITY: sql << "`agi` = "; break;
- case CHAR_ATTR_DEXTERITY: sql << "`dex` = "; break;
- case CHAR_ATTR_VITALITY: sql << "`vit` = "; break;
- case CHAR_ATTR_INTELLIGENCE: sql << "`int` = "; break;
- case CHAR_ATTR_WILLPOWER: sql << "`will` = "; break;
+ LOG_ERROR("DALStorage::updateCharacterPoints: " << e.what());
+ throw;
}
- sql << attribValue
- << " WHERE id = " << charId;
- mDb->execSql(sql.str());
}
/**
@@ -1156,6 +1185,50 @@ void Storage::updateExperience(int charId, int skillId, int skillValue)
}
/**
+ * Write a modification message about character attributes to the database.
+ * @param charId The Id of the character
+ * @param attrId The Id of the attribute
+ * @param base The base value of the attribute for this character
+ * @param mod The cached modified value for this character.
+ */
+
+void Storage::updateAttribute(int charId, unsigned int attrId,
+ double base, double mod)
+{
+ try {
+ std::ostringstream sql;
+ sql << "UPDATE " << CHAR_ATTR_TBL_NAME << " "
+ << "SET "
+ << "attr_base = '" << base << "', "
+ << "attr_mod = '" << mod << "' "
+ << "WHERE "
+ << "char_id = '" << charId << "' "
+ << "AND "
+ << "attr_id = '" << attrId << "';";
+ mDb->execSql(sql.str());
+ // If this has modified a row, we're done, it updated sucessfully.
+ if (mDb->getModifiedRows() > 0)
+ return;
+ // If it did not change anything, then the record didn't previously exist.
+ // Create it.
+ sql.clear();
+ sql.str("");
+ sql << "INSERT INTO " << CHAR_ATTR_TBL_NAME << " "
+ << "(char_id, attr_id, attr_base, attr_mod) VALUES ( "
+ << charId << ", "
+ << attrId << ", "
+ << base << ", "
+ << mod << ")";
+ mDb->execSql(sql.str());
+ }
+ catch (const dal::DbSqlQueryExecFailure &e)
+ {
+ LOG_ERROR("DALStorage::updateAttribute: " << e.what());
+ throw;
+ }
+}
+
+/**
* Write a modification message about character skills to the database.
* @param CharId ID of the character
* @param monsterId ID of the monster type
@@ -1386,7 +1459,7 @@ std::list<Guild*> Storage::getGuildList()
i != members.end();
++i)
{
- Character *character = getCharacter((*i).first, NULL);
+ Character *character = getCharacter((*i).first, 0);
if (character)
{
character->addGuild((*itr)->getName());
@@ -1508,7 +1581,7 @@ void Storage::setWorldStateVar(const std::string &name,
std::ostringstream updateStateVar;
updateStateVar << "UPDATE " << WORLD_STATES_TBL_NAME
<< " SET value = '" << value << "', "
- << " moddate = '" << time(NULL) << "' "
+ << " moddate = '" << time(0) << "' "
<< " WHERE state_name = '" << name << "'";
if (mapId >= 0)
@@ -1535,10 +1608,10 @@ void Storage::setWorldStateVar(const std::string &name,
}
else
{
- insertStateVar << "NULL , ";
+ insertStateVar << "0 , ";
}
insertStateVar << "'" << value << "', "
- << "'" << time(NULL) << "');";
+ << "'" << time(0) << "');";
mDb->execSql(insertStateVar.str());
}
catch (const dal::DbSqlQueryExecFailure &e)
@@ -1598,7 +1671,7 @@ void Storage::banCharacter(int id, int duration)
std::ostringstream sql;
sql << "update " << ACCOUNTS_TBL_NAME
<< " set level = '" << AL_BANNED << "', banned = '"
- << time(NULL) + duration * 60
+ << time(0) + duration * 60
<< "' where id = '" << info(0, 0) << "';";
mDb->execSql(sql.str());
}
@@ -1707,7 +1780,7 @@ void Storage::checkBannedAccounts()
sql << "update " << ACCOUNTS_TBL_NAME
<< " set level = " << AL_PLAYER << ", banned = 0"
<< " where level = " << AL_BANNED
- << " AND banned <= " << time(NULL) << ";";
+ << " AND banned <= " << time(0) << ";";
mDb->execSql(sql.str());
}
catch (const dal::DbSqlQueryExecFailure &e)
@@ -1776,7 +1849,7 @@ void Storage::storeLetter(Letter *letter)
<< letter->getSender()->getDatabaseID() << ", "
<< letter->getReceiver()->getDatabaseID() << ", "
<< letter->getExpiry() << ", "
- << time(NULL) << ", "
+ << time(0) << ", "
<< "?)";
if (mDb->prepareSql(sql.str()))
{
@@ -1798,7 +1871,7 @@ void Storage::storeLetter(Letter *letter)
<< " receiver_id = '" << letter->getReceiver()->getDatabaseID() << "', "
<< " letter_type = '" << letter->getType() << "', "
<< " expiration_date = '" << letter->getExpiry() << "', "
- << " sending_date = '" << time(NULL) << "', "
+ << " sending_date = '" << time(0) << "', "
<< " letter_text = ? "
<< " WHERE letter_id = '" << letter->getId() << "'";
@@ -1846,8 +1919,8 @@ Post *Storage::getStoredPost(int playerId)
for (unsigned int i = 0; i < post.rows(); i++ )
{
// load sender and receiver
- Character *sender = getCharacter(toUint(post(i, 1)), NULL);
- Character *receiver = getCharacter(toUint(post(i, 2)), NULL);
+ Character *sender = getCharacter(toUint(post(i, 1)), 0);
+ Character *receiver = getCharacter(toUint(post(i, 2)), 0);
Letter *letter = new Letter(toUint( post(0,3) ), sender, receiver);
@@ -2030,7 +2103,7 @@ void Storage::setOnlineStatus(int charId, bool online)
sql.clear();
sql.str("");
sql << "INSERT INTO " << ONLINE_USERS_TBL_NAME
- << " VALUES (" << charId << ", " << time(NULL) << ")";
+ << " VALUES (" << charId << ", " << time(0) << ")";
mDb->execSql(sql.str());
}
else
@@ -2060,7 +2133,7 @@ void Storage::addTransaction(const Transaction &trans)
<< " VALUES (NULL, " << trans.mCharacterId << ", "
<< trans.mAction << ", "
<< "?, "
- << time(NULL) << ")";
+ << time(0) << ")";
if (mDb->prepareSql(sql.str()))
{
mDb->bindValue(1, trans.mMessage);