Core/Achievements: Enabled saving progress and converted old saved data

This commit is contained in:
Shauren
2014-12-31 18:00:35 +01:00
parent c831c7548f
commit e5b9d815ba
3 changed files with 3620 additions and 37 deletions

View File

@@ -408,7 +408,7 @@ DROP TABLE IF EXISTS `character_achievement_progress`;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `character_achievement_progress` (
`guid` bigint(20) unsigned NOT NULL,
`criteria` smallint(5) unsigned NOT NULL,
`criteria` int(10) unsigned NOT NULL,
`counter` bigint(20) unsigned NOT NULL,
`date` int(10) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`guid`,`criteria`)
@@ -1816,7 +1816,7 @@ DROP TABLE IF EXISTS `guild_achievement_progress`;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `guild_achievement_progress` (
`guildId` bigint(20) unsigned NOT NULL,
`criteria` smallint(5) unsigned NOT NULL,
`criteria` int(10) unsigned NOT NULL,
`counter` bigint(20) unsigned NOT NULL,
`date` int(10) unsigned NOT NULL DEFAULT '0',
`completedGuid` bigint(20) unsigned NOT NULL DEFAULT '0',

File diff suppressed because it is too large Load Diff

View File

@@ -572,7 +572,6 @@ void AchievementMgr<Player>::SaveToDB(SQLTransaction& trans)
}
}
/*
if (!m_criteriaProgress.empty())
{
for (CriteriaProgressMap::iterator iter = m_criteriaProgress.begin(); iter != m_criteriaProgress.end(); ++iter)
@@ -582,14 +581,14 @@ void AchievementMgr<Player>::SaveToDB(SQLTransaction& trans)
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_ACHIEVEMENT_PROGRESS_BY_CRITERIA);
stmt->setUInt64(0, GetOwner()->GetGUID().GetCounter());
stmt->setUInt16(1, iter->first);
stmt->setUInt32(1, iter->first);
trans->Append(stmt);
if (iter->second.counter)
{
stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHAR_ACHIEVEMENT_PROGRESS);
stmt->setUInt64(0, GetOwner()->GetGUID().GetCounter());
stmt->setUInt16(1, iter->first);
stmt->setUInt32(1, iter->first);
stmt->setUInt32(2, iter->second.counter);
stmt->setUInt32(3, uint32(iter->second.date));
trans->Append(stmt);
@@ -598,7 +597,6 @@ void AchievementMgr<Player>::SaveToDB(SQLTransaction& trans)
iter->second.changed = false;
}
}
*/
}
template<>
@@ -629,7 +627,6 @@ void AchievementMgr<Guild>::SaveToDB(SQLTransaction& trans)
guidstr.str("");
}
/*
for (CriteriaProgressMap::const_iterator itr = m_criteriaProgress.begin(); itr != m_criteriaProgress.end(); ++itr)
{
if (!itr->second.changed)
@@ -637,18 +634,17 @@ void AchievementMgr<Guild>::SaveToDB(SQLTransaction& trans)
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_ACHIEVEMENT_CRITERIA);
stmt->setUInt64(0, GetOwner()->GetId());
stmt->setUInt16(1, itr->first);
stmt->setUInt32(1, itr->first);
trans->Append(stmt);
stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_GUILD_ACHIEVEMENT_CRITERIA);
stmt->setUInt64(0, GetOwner()->GetId());
stmt->setUInt16(1, itr->first);
stmt->setUInt32(1, itr->first);
stmt->setUInt64(2, itr->second.counter);
stmt->setUInt32(3, itr->second.date);
stmt->setUInt64(4, itr->second.PlayerGUID.GetCounter());
trans->Append(stmt);
}
*/
}
template<class T>
void AchievementMgr<T>::LoadFromDB(PreparedQueryResult achievementResult, PreparedQueryResult criteriaResult)
@@ -686,14 +682,13 @@ void AchievementMgr<Player>::LoadFromDB(PreparedQueryResult achievementResult, P
while (achievementResult->NextRow());
}
/*
if (criteriaResult)
{
time_t now = time(NULL);
do
{
Field* fields = criteriaResult->Fetch();
uint32 id = fields[0].GetUInt16();
uint32 id = fields[0].GetUInt32();
uint64 counter = fields[1].GetUInt64();
time_t date = time_t(fields[2].GetUInt32());
@@ -704,7 +699,7 @@ void AchievementMgr<Player>::LoadFromDB(PreparedQueryResult achievementResult, P
TC_LOG_ERROR("achievement", "Non-existing achievement criteria %u data removed from table `character_achievement_progress`.", id);
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_INVALID_ACHIEV_PROGRESS_CRITERIA);
stmt->setUInt16(0, uint16(id));
stmt->setUInt32(0, uint16(id));
CharacterDatabase.Execute(stmt);
continue;
@@ -720,7 +715,6 @@ void AchievementMgr<Player>::LoadFromDB(PreparedQueryResult achievementResult, P
}
while (criteriaResult->NextRow());
}
*/
}
template<>
@@ -751,14 +745,13 @@ void AchievementMgr<Guild>::LoadFromDB(PreparedQueryResult achievementResult, Pr
while (achievementResult->NextRow());
}
/*
if (criteriaResult)
{
time_t now = time(NULL);
do
{
Field* fields = criteriaResult->Fetch();
uint32 id = fields[0].GetUInt16();
uint32 id = fields[0].GetUInt32();
uint32 counter = fields[1].GetUInt32();
time_t date = time_t(fields[2].GetUInt32());
ObjectGuid::LowType guid = fields[3].GetUInt64();
@@ -770,7 +763,7 @@ void AchievementMgr<Guild>::LoadFromDB(PreparedQueryResult achievementResult, Pr
TC_LOG_ERROR("achievement", "Non-existing achievement criteria %u data removed from table `guild_achievement_progress`.", id);
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_INVALID_ACHIEV_PROGRESS_CRITERIA_GUILD);
stmt->setUInt16(0, uint16(id));
stmt->setUInt32(0, uint16(id));
CharacterDatabase.Execute(stmt);
continue;
}
@@ -785,7 +778,6 @@ void AchievementMgr<Guild>::LoadFromDB(PreparedQueryResult achievementResult, Pr
progress.changed = false;
} while (criteriaResult->NextRow());
}
*/
}
template<class T>
@@ -1324,6 +1316,7 @@ void AchievementMgr<T>::UpdateAchievementCriteria(AchievementCriteriaTypes type,
SetCriteriaProgress(achievementCriteria, referencePlayer->GetReputationMgr().GetExaltedFactionCount(), referencePlayer);
break;
case ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILLLINE_SPELLS:
case ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILL_LINE:
{
uint32 spellCount = 0;
for (PlayerSpellMap::const_iterator spellIter = referencePlayer->GetSpellMap().begin();
@@ -1349,21 +1342,6 @@ void AchievementMgr<T>::UpdateAchievementCriteria(AchievementCriteriaTypes type,
case ACHIEVEMENT_CRITERIA_TYPE_KNOWN_FACTIONS:
SetCriteriaProgress(achievementCriteria, referencePlayer->GetReputationMgr().GetVisibleFactionCount(), referencePlayer);
break;
case ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILL_LINE:
{
uint32 spellCount = 0;
for (PlayerSpellMap::const_iterator spellIter = referencePlayer->GetSpellMap().begin();
spellIter != referencePlayer->GetSpellMap().end();
++spellIter)
{
SkillLineAbilityMapBounds bounds = sSpellMgr->GetSkillLineAbilityMapBounds(spellIter->first);
for (SkillLineAbilityMap::const_iterator skillIter = bounds.first; skillIter != bounds.second; ++skillIter)
if (skillIter->second->SkillLine == achievementCriteria->Entry->Asset.SkillID)
spellCount++;
}
SetCriteriaProgress(achievementCriteria, spellCount, referencePlayer);
break;
}
case ACHIEVEMENT_CRITERIA_TYPE_EARN_HONORABLE_KILL:
SetCriteriaProgress(achievementCriteria, referencePlayer->GetUInt32Value(PLAYER_FIELD_LIFETIME_HONORABLE_KILLS), referencePlayer);
break;
@@ -2603,6 +2581,7 @@ bool AchievementMgr<T>::RequirementsSatisfied(AchievementCriteria const* achieve
return false;
break;
case ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILLLINE_SPELLS:
case ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILL_LINE:
if (miscValue1 && miscValue1 != achievementCriteria->Entry->Asset.SkillID)
return false;
break;
@@ -2616,10 +2595,6 @@ bool AchievementMgr<T>::RequirementsSatisfied(AchievementCriteria const* achieve
return false;
break;
}
case ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILL_LINE:
if (miscValue1 && miscValue1 != achievementCriteria->Entry->Asset.SkillID)
return false;
break;
case ACHIEVEMENT_CRITERIA_TYPE_HK_CLASS:
if (!miscValue1 || miscValue1 != achievementCriteria->Entry->Asset.ClassID)
return false;