Changed: #1304: Adding mission histories for CGuild

--HG--
branch : gsoc2011-guildmissions
This commit is contained in:
Fabien_HENON 2011-07-04 15:06:11 +02:00
parent 74a6cc26e6
commit e92762ad8b
2 changed files with 49 additions and 8 deletions

View file

@ -704,6 +704,8 @@ void CGuild::removeMission( uint idx, TMissionResult result)
CMissionTemplate *tpl = CMissionManager::getInstance()->getTemplate(_Missions[idx]->getTemplateId()); CMissionTemplate *tpl = CMissionManager::getInstance()->getTemplate(_Missions[idx]->getTemplateId());
updateMissionHistories( _Missions[idx]->getTemplateId(), result);
if ( tpl && !tpl->Tags.NoList ) if ( tpl && !tpl->Tags.NoList )
{ {
_Missions[idx]->clearUsersJournalEntry(); _Missions[idx]->clearUsersJournalEntry();
@ -717,21 +719,53 @@ void CGuild::removeMission( uint idx, TMissionResult result)
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void CGuild::addSuccessfulMission(CMissionTemplate * templ) void CGuild::addSuccessfulMission(CMissionTemplate * templ)
{ {
/*TMissionHistory &mh = _MissionHistories[templ.Alias]; TMissionHistory &mh = _MissionHistories[templ->Alias];
mh.Successfull = true;*/ mh.Successfull = true;
/// TODO: Add the mission histories }
//----------------------------------------------------------------------------
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) bool CGuild::processMissionEvent( CMissionEvent & event, TAIAlias alias)
{ {
return true; std::list<CMissionEvent*> listEvents;
listEvents.push_back(&event);
return processGuildMissionEvent(listEvents, alias);
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool CGuild::processGuildMissionEvent(std::list< CMissionEvent *> & eventList, TAIAlias missionAlias) 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) bool CGuild::isMissionSuccessfull(TAIAlias alias)
{ {
/*std::map<TAIAlias, TMissionHistory>::iterator it(_MissionHistories.find(alias)); std::map<TAIAlias, TMissionHistory>::iterator it(_MissionHistories.find(alias));
if (it != _MissionHistories.end()) if (it != _MissionHistories.end())
return it->second.Successfull;*/ return it->second.Successfull;
/// TODO: Add the mission histories
return false; return false;
} }

View file

@ -32,6 +32,10 @@
class CMissionGuild; class CMissionGuild;
class CGuildMember; class CGuildMember;
/* Storage class for mission history data.
*/
struct TMissionHistory;
/** /**
* A guild in ryzom * A guild in ryzom
@ -189,6 +193,8 @@ public:
} }
void removeMission( uint idx, TMissionResult result); void removeMission( uint idx, TMissionResult result);
void addSuccessfulMission(CMissionTemplate * templ); void addSuccessfulMission(CMissionTemplate * templ);
void clearSuccessfulMissions();
void updateMissionHistories(TAIAlias missionAlias, uint32 result);
bool processMissionEvent( CMissionEvent & event, TAIAlias alias = CAIAliasTranslator::Invalid); bool processMissionEvent( CMissionEvent & event, TAIAlias alias = CAIAliasTranslator::Invalid);
bool processGuildMissionEvent(std::list< CMissionEvent * > & eventList, TAIAlias missionAlias ); bool processGuildMissionEvent(std::list< CMissionEvent * > & eventList, TAIAlias missionAlias );
bool processGuildMissionStepEvent(std::list< CMissionEvent* > & eventList, TAIAlias missionAlias, uint32 stepIndex); bool processGuildMissionStepEvent(std::list< CMissionEvent* > & eventList, TAIAlias missionAlias, uint32 stepIndex);
@ -378,6 +384,8 @@ private:
///the missions took by the guild ///the missions took by the guild
std::vector<CMissionGuild*> _Missions; std::vector<CMissionGuild*> _Missions;
/// Successful missions
std::map<TAIAlias, TMissionHistory> _MissionHistories;
NLMISC_COMMAND_FRIEND( guildDB ); NLMISC_COMMAND_FRIEND( guildDB );
}; };