summaryrefslogtreecommitdiff
path: root/src/account-server/storage.cpp
diff options
context:
space:
mode:
authorErik Schilling <ablu.erikschilling@googlemail.com>2013-02-17 12:24:45 +0100
committerErik Schilling <ablu.erikschilling@googlemail.com>2013-08-26 22:56:47 +0200
commit44ee071d7ece5a2023f79307f36e8a244c9e7b3a (patch)
tree06b7fcea59bbbf1963b460ca9b678d0ea6fa90e4 /src/account-server/storage.cpp
parente3a1e9c89e102dbf961c624435c495c759776312 (diff)
downloadmanaserv-44ee071d7ece5a2023f79307f36e8a244c9e7b3a.tar.gz
manaserv-44ee071d7ece5a2023f79307f36e8a244c9e7b3a.tar.bz2
manaserv-44ee071d7ece5a2023f79307f36e8a244c9e7b3a.tar.xz
manaserv-44ee071d7ece5a2023f79307f36e8a244c9e7b3a.zip
Removed skills
This removes support for skills. The plan is to allow to implement the skills as they were implemented before via attributes. This adds a lot more flexibility to the server creators while also removing the confusion about skills and attributes. So this change does: - Remove the skillmanager with all its calls, the skill xml file, etc - Move exp giving to the script engine: --> Allows to implement the old behaviour (and more) in the scripts - Remove the exp tag from the monster definition: + Since the server itself does not require it anymore it feels wrong to require it for EVERY monster. TODO: Add a system to add properties to the monsters/items.xml which allow defining things like the exp and allows to read the value from the script engine. + Small drawback, but it should not be hard to implement this property system. - Drop the level networking and calculation. + level calculation will happen via the attribute system later but i would prefer to do this in a seperate patch since this patch already got longer than expected especially since this requires to make setting correction points and available status points scriptable. + The level would be simply set as a attribute, the int number of it will be the level, the remaining digits will be the % number till the next levelup. - NOT remove any existing skill tables in the database update scripts. + There is no way to move them into the attribute table in a unified way (there are too many different way they could have been used). So server admins have to care about moving theirs skills to attributes themselves. + Keeping the old tables does not hurt for existing databases. So removing does not give any advantage/is required anyway. The now obsolote info about the EXP transaction is not removed for updated databases either. (The update script basically only bumps the version number without doing anything else. - bump the network protocol version --> old clients won't be able to connect. - bump the database version --> serveradmins need to update their db.
Diffstat (limited to 'src/account-server/storage.cpp')
-rw-r--r--src/account-server/storage.cpp130
1 files changed, 6 insertions, 124 deletions
diff --git a/src/account-server/storage.cpp b/src/account-server/storage.cpp
index 965024a0..2ddb2e08 100644
--- a/src/account-server/storage.cpp
+++ b/src/account-server/storage.cpp
@@ -75,7 +75,6 @@ static const char *DB_VERSION_PARAMETER = "database_version";
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_ABILITIES_TBL_NAME = "mana_char_abilities";
@@ -363,13 +362,12 @@ CharacterData *Storage::getCharacterBySQL(Account *owner)
character->setGender(toUshort(charInfo(0, 3)));
character->setHairStyle(toUshort(charInfo(0, 4)));
character->setHairColor(toUshort(charInfo(0, 5)));
- character->setLevel(toUshort(charInfo(0, 6)));
- character->setCharacterPoints(toUshort(charInfo(0, 7)));
- character->setCorrectionPoints(toUshort(charInfo(0, 8)));
- Point pos(toInt(charInfo(0, 9)), toInt(charInfo(0, 10)));
+ character->setCharacterPoints(toUshort(charInfo(0, 6)));
+ character->setCorrectionPoints(toUshort(charInfo(0, 7)));
+ Point pos(toInt(charInfo(0, 8)), toInt(charInfo(0, 9)));
character->setPosition(pos);
- int mapId = toUint(charInfo(0, 11));
+ int mapId = toUint(charInfo(0, 10));
if (mapId > 0)
{
character->setMapId(mapId);
@@ -381,7 +379,7 @@ CharacterData *Storage::getCharacterBySQL(Account *owner)
character->setMapId(Configuration::getValue("char_defaultMap", 1));
}
- character->setCharacterSlot(toUint(charInfo(0, 12)));
+ character->setCharacterSlot(toUint(charInfo(0, 11)));
// Fill the account-related fields. Last step, as it may require a new
// SQL query.
@@ -422,25 +420,6 @@ CharacterData *Storage::getCharacterBySQL(Account *owner)
s.clear();
s.str("");
- // Load skills.
- s << "SELECT skill_id, skill_exp "
- << "FROM " << CHAR_SKILLS_TBL_NAME
- << " WHERE char_id = " << character->getDatabaseID();
-
- const dal::RecordSet &skillInfo = mDb->execSql(s.str());
- if (!skillInfo.isEmpty())
- {
- const unsigned nRows = skillInfo.rows();
- for (unsigned row = 0; row < nRows; ++row)
- {
- unsigned id = toUint(skillInfo(row, 0));
- character->setExperience(id, toInt(skillInfo(row, 1)));
- }
- }
-
- s.clear();
- s.str("");
-
// Load the status effects
s << "select status_id, status_time FROM "
<< CHAR_STATUS_EFFECTS_TBL_NAME
@@ -723,7 +702,6 @@ bool Storage::updateCharacter(CharacterData *character)
<< "gender = '" << character->getGender() << "', "
<< "hair_style = '" << character->getHairStyle() << "', "
<< "hair_color = '" << character->getHairColor() << "', "
- << "level = '" << character->getLevel() << "', "
<< "char_pts = '" << character->getCharacterPoints() << "', "
<< "correct_pts = '"<< character->getCorrectionPoints() << "', "
<< "x = '" << character->getPosition().x << "', "
@@ -754,23 +732,6 @@ bool Storage::updateCharacter(CharacterData *character)
"SQL query failure: ", e);
}
- // Character's skills
- try
- {
- std::map<int, int>::const_iterator skill_it;
- for (skill_it = character->mExperience.begin();
- skill_it != character->mExperience.end(); skill_it++)
- {
- updateExperience(character->getDatabaseID(),
- skill_it->first, skill_it->second);
- }
- }
- catch (const dal::DbSqlQueryExecFailure& e)
- {
- utils::throwError("(DALStorage::updateCharacter #3) "
- "SQL query failure: ", e);
- }
-
// Character's kill count
try
{
@@ -1022,14 +983,13 @@ void Storage::flush(Account *account)
sqlInsertCharactersTable
<< "insert into " << CHARACTERS_TBL_NAME
<< " (user_id, name, gender, hair_style, hair_color,"
- << " level, char_pts, correct_pts,"
+ << " char_pts, correct_pts,"
<< " x, y, map_id, slot) values ("
<< account->getID() << ", \""
<< character->getName() << "\", "
<< character->getGender() << ", "
<< (int)character->getHairStyle() << ", "
<< (int)character->getHairColor() << ", "
- << (int)character->getLevel() << ", "
<< (int)character->getCharacterPoints() << ", "
<< (int)character->getCorrectionPoints() << ", "
<< character->getPosition().x << ", "
@@ -1053,15 +1013,6 @@ void Storage::flush(Account *account)
attr_it->second.base,
attr_it->second.modified);
}
-
- // Update the characters skill
- std::map<int, int>::const_iterator skill_it;
- for (skill_it = character->mExperience.begin();
- skill_it != character->mExperience.end(); skill_it++)
- {
- updateExperience(character->getDatabaseID(),
- skill_it->first, skill_it->second);
- }
}
}
@@ -1173,51 +1124,6 @@ void Storage::updateCharacterPoints(int charId,
}
}
-void Storage::updateExperience(int charId, int skillId, int skillValue)
-{
- try
- {
- std::ostringstream sql;
- // If experience has decreased to 0 we don't store it anymore,
- // since it's the default behaviour.
- if (skillValue == 0)
- {
- sql << "DELETE FROM " << CHAR_SKILLS_TBL_NAME
- << " WHERE char_id = " << charId
- << " AND skill_id = " << skillId;
- mDb->execSql(sql.str());
- return;
- }
-
- // Try to update the skill
- sql.clear();
- sql.str("");
- sql << "UPDATE " << CHAR_SKILLS_TBL_NAME
- << " SET skill_exp = " << skillValue
- << " WHERE char_id = " << charId
- << " AND skill_id = " << skillId;
- mDb->execSql(sql.str());
-
- // Check if the update has modified a row
- if (mDb->getModifiedRows() > 0)
- return;
-
- sql.clear();
- sql.str("");
- sql << "INSERT INTO " << CHAR_SKILLS_TBL_NAME << " "
- << "(char_id, skill_id, skill_exp) VALUES ( "
- << charId << ", "
- << skillId << ", "
- << skillValue << ")";
- mDb->execSql(sql.str());
- }
- catch (const dal::DbSqlQueryExecFailure &e)
- {
- utils::throwError("(DALStorage::updateExperience) SQL query failure: ",
- e);
- }
-}
-
void Storage::updateAttribute(int charId, unsigned attrId,
double base, double mod)
{
@@ -1795,13 +1701,6 @@ void Storage::delCharacter(int charId) const
<< " WHERE owner_id = '" << charId << "';";
mDb->execSql(sql.str());
- // Delete the skills of the character
- sql.clear();
- sql.str("");
- sql << "DELETE FROM " << CHAR_SKILLS_TBL_NAME
- << " WHERE char_id = '" << charId << "';";
- mDb->execSql(sql.str());
-
// Delete from the quests table
sql.clear();
sql.str("");
@@ -1886,23 +1785,6 @@ void Storage::setAccountLevel(int id, int level)
}
}
-void Storage::setPlayerLevel(int id, int level)
-{
- try
- {
- std::ostringstream sql;
- sql << "update " << CHARACTERS_TBL_NAME
- << " set level = " << level
- << " where id = " << id << ";";
- mDb->execSql(sql.str());
- }
- catch (const dal::DbSqlQueryExecFailure &e)
- {
- utils::throwError("(DALStorage::setPlayerLevel) SQL query failure: ",
- e);
- }
-}
-
void Storage::storeLetter(Letter *letter)
{
try