Changed: #1304: Adding guild mission support in functions acceptExchange and processMissionEventList of the CCharacter class

--HG--
branch : gsoc2011-guildmissions
hg/feature/gsoc2012-fabien
Fabien_HENON 14 years ago
parent c175338c7f
commit 74a6cc26e6

@ -728,6 +728,30 @@ bool CGuild::processMissionEvent( CMissionEvent & event, TAIAlias alias)
return true;
}
//----------------------------------------------------------------------------
bool CGuild::processGuildMissionEvent(std::list< CMissionEvent *> & eventList, TAIAlias missionAlias)
{
return true;
}
//----------------------------------------------------------------------------
bool CGuild::processGuildMissionStepEvent(std::list< CMissionEvent*> & eventList, TAIAlias missionAlias, uint32 stepIndex)
{
return true;
}
//----------------------------------------------------------------------------
CMissionGuild* CGuild::getMissionByAlias( TAIAlias missionAlias )
{
const uint size = (uint)_Missions.size();
for ( uint i = 0; i < size; i++ )
{
if ( _Missions[i] && _Missions[i]->getTemplateId() == missionAlias )
return _Missions[i];
}
return NULL;
}
//----------------------------------------------------------------------------
bool CGuild::isMissionSuccessfull(TAIAlias alias)
{

@ -190,6 +190,9 @@ public:
void removeMission( uint idx, TMissionResult result);
void addSuccessfulMission(CMissionTemplate * templ);
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);
CMissionGuild* getMissionByAlias( TAIAlias missionAlias );
bool isMissionSuccessfull(TAIAlias alias);
///\return the mission
inline std::vector<CMissionGuild*> & getMissions()

@ -10708,6 +10708,7 @@ void CCharacter::acceptExchange(uint8 exchangeId)
}
CTeam * team = TeamManager.getRealTeam( _TeamId );
CGuild* guild = CGuildManager::getInstance()->getGuildFromId( _GuildId );
if (_BotGift == NULL)
{
nlwarning("Player %s has no bot gift", _Id.toString().c_str());
@ -10731,6 +10732,15 @@ void CCharacter::acceptExchange(uint8 exchangeId)
}
mission = team->getMissionByAlias( missionAlias );
}
else if (type == MISSION_DESC::Guild)
{
if (guild == NULL)
{
nlwarning("CCharacter::acceptExchange : character %s -> no guild",_Id.toString().c_str() );
return;
}
mission = guild->getMissionByAlias( missionAlias );
}
vector<CGameItemPtr> vect;
vector<CPetAnimal> exchangePlayerPets;
@ -10764,6 +10774,8 @@ void CCharacter::acceptExchange(uint8 exchangeId)
processMissionStepUserEvent( eventList,missionAlias,stepIndex );
else if ( type == MISSION_DESC::Group )
team->processTeamMissionStepEvent( eventList,missionAlias,stepIndex );
else if ( type == MISSION_DESC::Guild )
guild->processGuildMissionStepEvent( eventList,missionAlias,stepIndex );
eventList.pop_front();
for ( std::list< CMissionEvent* >::iterator it = eventList.begin(); it != eventList.end(); ++it )
processMissionEvent(*(*it));
@ -10783,6 +10795,8 @@ void CCharacter::acceptExchange(uint8 exchangeId)
processMissionStepUserEvent( eventList,missionAlias,stepIndex );
else if ( type == MISSION_DESC::Group )
team->processTeamMissionStepEvent( eventList,missionAlias,stepIndex );
else if ( type == MISSION_DESC::Guild )
guild->processGuildMissionStepEvent( eventList,missionAlias,stepIndex );
eventList.pop_front();
for ( std::list< CMissionEvent* >::iterator it = eventList.begin(); it != eventList.end(); ++it )
processMissionEvent(*(*it));
@ -11615,7 +11629,7 @@ bool CCharacter::processMissionEventList( std::list< CMissionEvent* > & eventLis
bool processed = false;
bool firstEvent = true;
CGuild * guild = NULL;
CGuild * guild = CGuildManager::getInstance()->getGuildFromId( _GuildId );
while ( !eventList.empty() )
{
bool eventProcessed = false;
@ -11652,6 +11666,13 @@ bool CCharacter::processMissionEventList( std::list< CMissionEvent* > & eventLis
eventProcessed = team->processTeamMissionEvent(eventList, alias);
}
// THIRD - Check with guild missions (if event not already processed and char belongs to a guild)
if (!eventProcessed && (event.Restriction != CMissionEvent::NoGroup))
{
if (guild != NULL)
eventProcessed = guild->processGuildMissionEvent(eventList, alias);
}
processed |= eventProcessed;
// the first event of the list was processed, so we remove it.

Loading…
Cancel
Save