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());
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<CMissionEvent*> 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<TAIAlias, TMissionHistory>::iterator it(_MissionHistories.find(alias));
std::map<TAIAlias, TMissionHistory>::iterator it(_MissionHistories.find(alias));
if (it != _MissionHistories.end())
return it->second.Successfull;*/
/// TODO: Add the mission histories
return it->second.Successfull;
return false;
}

View file

@ -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<CMissionGuild*> _Missions;
/// Successful missions
std::map<TAIAlias, TMissionHistory> _MissionHistories;
NLMISC_COMMAND_FRIEND( guildDB );
};