From 70b16fc8774eacb972a3cb5fe18879f3bdf1c1e7 Mon Sep 17 00:00:00 2001 From: Fabien_HENON Date: Mon, 4 Jul 2011 15:06:11 +0200 Subject: [PATCH] Changed: #1304: Adding mission histories for CGuild --- .../guild_manager/guild.cpp | 49 ++++++++++++++++--- .../guild_manager/guild.h | 8 +++ 2 files changed, 49 insertions(+), 8 deletions(-) diff --git a/code/ryzom/server/src/entities_game_service/guild_manager/guild.cpp b/code/ryzom/server/src/entities_game_service/guild_manager/guild.cpp index 1a5c9fff3..121aed2f9 100644 --- a/code/ryzom/server/src/entities_game_service/guild_manager/guild.cpp +++ b/code/ryzom/server/src/entities_game_service/guild_manager/guild.cpp @@ -704,6 +704,8 @@ void CGuild::removeMission( uint idx, TMissionResult result) CMissionTemplate *tpl = CMissionManager::getInstance()->getTemplate(_Missions[idx]->getTemplateId()); + updateMissionHistories( _Missions[idx]->getTemplateId(), result); + if ( tpl && !tpl->Tags.NoList ) { _Missions[idx]->clearUsersJournalEntry(); @@ -717,21 +719,53 @@ void CGuild::removeMission( uint idx, TMissionResult result) //---------------------------------------------------------------------------- void CGuild::addSuccessfulMission(CMissionTemplate * templ) { - /*TMissionHistory &mh = _MissionHistories[templ.Alias]; - mh.Successfull = true;*/ - /// TODO: Add the mission histories + TMissionHistory &mh = _MissionHistories[templ->Alias]; + mh.Successfull = true; +} + +//---------------------------------------------------------------------------- +void CGuild::clearSuccessfulMissions() +{ + _MissionHistories.clear(); +} + +//---------------------------------------------------------------------------- +void CGuild::updateMissionHistories(TAIAlias missionAlias, uint32 result) +{ + TMissionHistory &mh = _MissionHistories[missionAlias]; + + switch(result) + { + case mr_success: + case mr_forced: + mh.Successfull = true; + // validate last try date + _MissionHistories[missionAlias].LastSuccessDate = CTickEventHandler::getGameCycle(); + break; + } } //---------------------------------------------------------------------------- bool CGuild::processMissionEvent( CMissionEvent & event, TAIAlias alias) { - return true; + std::list listEvents; + listEvents.push_back(&event); + return processGuildMissionEvent(listEvents, alias); } //---------------------------------------------------------------------------- bool CGuild::processGuildMissionEvent(std::list< CMissionEvent *> & eventList, TAIAlias missionAlias) { - return true; + for (uint i = 0; i < _Missions.size(); i++ ) + { + nlassert( _Missions[i] ); + if ( missionAlias == CAIAliasTranslator::Invalid || _Missions[i]->getTemplateId() == missionAlias ) + { + if ( processGuildMissionStepEvent( eventList, _Missions[i]->getTemplateId() ,0xFFFFFFFF) ) + return true; + } + } + return false; } //---------------------------------------------------------------------------- @@ -755,10 +789,9 @@ CMissionGuild* CGuild::getMissionByAlias( TAIAlias missionAlias ) //---------------------------------------------------------------------------- bool CGuild::isMissionSuccessfull(TAIAlias alias) { - /*std::map::iterator it(_MissionHistories.find(alias)); + std::map::iterator it(_MissionHistories.find(alias)); if (it != _MissionHistories.end()) - return it->second.Successfull;*/ - /// TODO: Add the mission histories + return it->second.Successfull; return false; } diff --git a/code/ryzom/server/src/entities_game_service/guild_manager/guild.h b/code/ryzom/server/src/entities_game_service/guild_manager/guild.h index b3b8e4e01..61dc97dd2 100644 --- a/code/ryzom/server/src/entities_game_service/guild_manager/guild.h +++ b/code/ryzom/server/src/entities_game_service/guild_manager/guild.h @@ -32,6 +32,10 @@ class CMissionGuild; class CGuildMember; +/* Storage class for mission history data. +*/ +struct TMissionHistory; + /** * A guild in ryzom @@ -189,6 +193,8 @@ public: } void removeMission( uint idx, TMissionResult result); void addSuccessfulMission(CMissionTemplate * templ); + void clearSuccessfulMissions(); + void updateMissionHistories(TAIAlias missionAlias, uint32 result); bool processMissionEvent( CMissionEvent & event, TAIAlias alias = CAIAliasTranslator::Invalid); bool processGuildMissionEvent(std::list< CMissionEvent * > & eventList, TAIAlias missionAlias ); bool processGuildMissionStepEvent(std::list< CMissionEvent* > & eventList, TAIAlias missionAlias, uint32 stepIndex); @@ -378,6 +384,8 @@ private: ///the missions took by the guild std::vector _Missions; + /// Successful missions + std::map _MissionHistories; NLMISC_COMMAND_FRIEND( guildDB ); };