From b16d22977b16594f7601835b3849be429ccaa5bc Mon Sep 17 00:00:00 2001 From: Fabien_HENON Date: Wed, 29 Jun 2011 14:44:30 +0200 Subject: [PATCH] Changed: #1304: Implementation of basic CGuild functions for guild missions --- .../guild_manager/guild.cpp | 44 ++++++++++++++++--- .../guild_manager/guild.h | 27 +++++++++--- 2 files changed, 60 insertions(+), 11 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 56a2606dd..ccf55d54b 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 @@ -34,6 +34,7 @@ #include "outpost_manager/outpost_manager.h" #include "primitives_parser.h" #include "modules/shard_unifier_client.h" +#include "mission_manager/mission_manager.h" /// todo guild remove entity id translator #include "nel/misc/eid_translator.h" @@ -686,23 +687,54 @@ void CGuild::unregisterGuild() // //} - //---------------------------------------------------------------------------- -void CGuild::removeMission(CMissionGuild * mission, TMissionResult result) +void CGuild::removeMission( uint idx, TMissionResult result) { - /// todo guild mission + if ( idx >= _Missions.size() ) + return; + + /// if the mission was finished, the result is success + if ( _Missions[idx]->getFinished() ) + { + if ( _Missions[idx]->getMissionSuccess() ) + result = mr_success; + else + result = mr_fail; + } + + CMissionTemplate *tpl = CMissionManager::getInstance()->getTemplate(_Missions[idx]->getTemplateId()); + + if ( tpl && !tpl->Tags.NoList ) + { + _Missions[idx]->clearUsersJournalEntry(); + } + + CMissionManager::getInstance()->deInstanciateMission(_Missions[idx]); + delete _Missions[idx]; + _Missions.erase(_Missions.begin() + idx) ; } //---------------------------------------------------------------------------- void CGuild::addSuccessfulMission(CMissionTemplate * templ) { - /// todo guild mission + /*TMissionHistory &mh = _MissionHistories[templ.Alias]; + mh.Successfull = true;*/ + /// TODO: Add the mission histories } //---------------------------------------------------------------------------- -bool CGuild::processMissionEvent( CMissionEvent & event, TAIAlias alias ) +bool CGuild::processMissionEvent( CMissionEvent & event, TAIAlias alias) { - /// todo guild mission + return true; +} + +//---------------------------------------------------------------------------- +bool CGuild::isMissionSuccessfull(TAIAlias alias) +{ + /*std::map::iterator it(_MissionHistories.find(alias)); + if (it != _MissionHistories.end()) + return it->second.Successfull;*/ + /// TODO: Add the mission histories 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 ecedbf9ee..342174ebb 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 @@ -27,6 +27,7 @@ #include "outpost_manager/outpost_guild_db_updater.h" #include "guild_interface.h" #include "database_guild.h" +#include "mission_manager/mission_guild.h" class CMissionGuild; class CGuildMember; @@ -176,17 +177,30 @@ public: ///\name Mission management //@{ - void removeMission(CMissionGuild * mission, TMissionResult result); + void removeMission(CMissionGuild * mission, TMissionResult result) + { + for (uint i = 0; i < _Missions.size(); i++) + { + if ( _Missions[i] == mission ) + { + removeMission(i, result); + } + } + } + void removeMission( uint idx, TMissionResult result); void addSuccessfulMission(CMissionTemplate * templ); bool processMissionEvent( CMissionEvent & event, TAIAlias alias = CAIAliasTranslator::Invalid); + bool isMissionSuccessfull(TAIAlias alias); ///\return the mission inline std::vector & getMissions() { - return std::vector(); - // To Do + return _Missions; + } + void addMission(CMissionGuild* guildMission) + { + _Missions.push_back(guildMission); + guildMission->updateUsersJournalEntry(); } - void addMission(CMissionGuild* guildMission) {} - bool isMissionSuccessfull(TAIAlias alias) { return false; } //@} /// inventory management @@ -359,6 +373,9 @@ private: /// list of outposts challenged by guild std::vector _ChallengedOutposts; + ///the missions took by the guild + std::vector _Missions; + NLMISC_COMMAND_FRIEND( guildDB ); }; #endif // RY_GUILD_H