From 7264e6c1bf790a3c1cf46492ce30d06fa43ee768 Mon Sep 17 00:00:00 2001 From: Fabien_HENON Date: Tue, 7 Jun 2011 14:42:00 +0200 Subject: [PATCH] Changed: #1304: Updating CMissionGuild for guild missions. Implementation of the functions: - updateUsersJournalEntry - clearUsersJournalEntry --- .../guild_manager/guild.h | 5 ++ .../mission_manager/mission_guild.cpp | 69 ++++++++++++++++++- .../mission_manager/mission_manager.cpp | 4 ++ .../mission_manager/missions_commands.cpp | 14 +++- 4 files changed, 88 insertions(+), 4 deletions(-) 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 e740540ca..3f3b04eb6 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 @@ -179,6 +179,11 @@ public: void removeMission(CMissionGuild * mission, TMissionResult result); void addSuccessfulMission(CMissionTemplate * templ); bool processMissionEvent( CMissionEvent & event, TAIAlias alias = CAIAliasTranslator::Invalid); + ///\return the mission + inline std::vector & getMissions() + { + // To Do + } //@} /// inventory management diff --git a/code/ryzom/server/src/entities_game_service/mission_manager/mission_guild.cpp b/code/ryzom/server/src/entities_game_service/mission_manager/mission_guild.cpp index d3bb2c106..63b74e997 100644 --- a/code/ryzom/server/src/entities_game_service/mission_manager/mission_guild.cpp +++ b/code/ryzom/server/src/entities_game_service/mission_manager/mission_guild.cpp @@ -25,18 +25,83 @@ #include "player_manager/player.h" #include "player_manager/character.h" +using namespace std; +using namespace NLMISC; + NL_INSTANCE_COUNTER_IMPL(CMissionGuild); //---------------------------------------------------------------------------- void CMissionGuild::updateUsersJournalEntry() { - /// todo guild mission + CGuild * guild = CGuildManager::getInstance()->getGuildFromId( _GuildId ); + if (!guild) + { + nlwarning( "cant find guild ID : %d", _GuildId ); + return; + } + + for ( std::map::iterator it = guild->getMembersBegin(); + it != guild->getMembersEnd();++it ) + { + CCharacter * user = PlayerManager.getChar( it->first ); + if ( !user ) + { + nlwarning( "cant find user %s", it->first.toString().c_str() ); + continue; + } + updateUserJournalEntry(*user,"GROUP:"); + } } //---------------------------------------------------------------------------- void CMissionGuild::clearUsersJournalEntry() { - /// todo guild mission + CGuild * guild = CGuildManager::getInstance()->getGuildFromId( _GuildId ); + if (!guild) + { + nlwarning( "cant find guild ID : %d", _GuildId ); + return; + } + + for ( std::map::iterator it = guild->getMembersBegin(); + it != guild->getMembersEnd();++it ) + { + CCharacter * user = PlayerManager.getChar( it->first ); + if ( !user ) + { + nlwarning( "cant find user %s", it->first.toString().c_str() ); + continue; + } + + CBankAccessor_PLR::TGROUP::TMISSIONS::TArray &missionItem = CBankAccessor_PLR::getGROUP().getMISSIONS().getArray(_ClientIndex); + // user->_PropertyDatabase.setProp( NLMISC::toString( "GROUP:MISSIONS:%u:TYPE",_ClientIndex), 0); + missionItem.setTYPE(user->_PropertyDatabase, 0); + // user->_PropertyDatabase.setProp( NLMISC::toString( "GROUP:MISSIONS:%u:ICON",_ClientIndex), 0); + missionItem.setICON(user->_PropertyDatabase, CSheetId::Unknown); + // user->_PropertyDatabase.setProp( NLMISC::toString( "GROUP:MISSIONS:%u:TITLE",_ClientIndex), 0); + missionItem.setTITLE(user->_PropertyDatabase, 0); + // user->_PropertyDatabase.setProp( NLMISC::toString( "GROUP:MISSIONS:%u:DETAIL_TEXT",_ClientIndex), 0); + missionItem.setDETAIL_TEXT(user->_PropertyDatabase, 0); + // user->_PropertyDatabase.setProp( NLMISC::toString( "GROUP:MISSIONS:%u:END_DATE",_ClientIndex), 0 ); + missionItem.setEND_DATE(user->_PropertyDatabase, 0); + // user->_PropertyDatabase.setProp( NLMISC::toString( "GROUP:MISSIONS:%u:BEGIN_DATE",_ClientIndex), 0 ); + missionItem.setBEGIN_DATE(user->_PropertyDatabase, 0); + for (uint i = 0; i < NB_JOURNAL_COORDS; i++) + { + CBankAccessor_PLR::TGROUP::TMISSIONS::TArray::TTARGET &targetItem = missionItem.getTARGET(i); + // user->_PropertyDatabase.setProp( NLMISC::toString( "GROUP:MISSIONS:%u:TARGET%u:TITLE",_ClientIndex,i), 0); + targetItem.setTITLE(user->_PropertyDatabase, 0); + // user->_PropertyDatabase.setProp( NLMISC::toString( "GROUP:MISSIONS:%u:TARGET%u:X",_ClientIndex,i), 0); + targetItem.setX(user->_PropertyDatabase, 0); + // user->_PropertyDatabase.setProp( NLMISC::toString( "GROUP:MISSIONS:%u:TARGET%u:Y",_ClientIndex,i), 0); + targetItem.setY(user->_PropertyDatabase, 0); + } + for (uint i = 0; i < NB_STEP_PER_MISSION; i++) + { + // user->_PropertyDatabase.setProp( NLMISC::toString( "GROUP:MISSIONS:%u:GOALS:%u:TEXT",_ClientIndex,i), 0); + missionItem.getGOALS().getArray(i).setTEXT(user->_PropertyDatabase, 0); + } + } } diff --git a/code/ryzom/server/src/entities_game_service/mission_manager/mission_manager.cpp b/code/ryzom/server/src/entities_game_service/mission_manager/mission_manager.cpp index b0bd41ffb..55a08ef4f 100644 --- a/code/ryzom/server/src/entities_game_service/mission_manager/mission_manager.cpp +++ b/code/ryzom/server/src/entities_game_service/mission_manager/mission_manager.cpp @@ -846,6 +846,10 @@ void CMissionManager::instanciateMission(CCharacter* user,TAIAlias alias, TAIAl inst = module->pickMission( templ->Alias ); if (!inst) return; + + /// /!\ Do the same thing that the team missions but with the loop: for ( uint i = MaxGroupMissionCount; i < MaxGroupMissionCount + MaxGuildMissionCount; i++ ) + /// Instead of for ( uint i = 0; i < MaxGroupMissionCount; i++ ), so that we use available space for guild missions + /// todo guild mission : see solo /* todo guild mission : implement that in module diff --git a/code/ryzom/server/src/entities_game_service/mission_manager/missions_commands.cpp b/code/ryzom/server/src/entities_game_service/mission_manager/missions_commands.cpp index 78229d3a8..a5f0f863f 100644 --- a/code/ryzom/server/src/entities_game_service/mission_manager/missions_commands.cpp +++ b/code/ryzom/server/src/entities_game_service/mission_manager/missions_commands.cpp @@ -30,7 +30,9 @@ #include "team_manager/team_manager.h" #include "mission_manager/mission_team.h" #include "mission_manager/mission_step_ai.h" +#include "mission_manager/mission_guild.h" #include "guild_manager/guild_manager.h" +#include "guild_manager/guild.h" #include "admin.h" #include "creature_manager/creature_manager.h" @@ -81,10 +83,18 @@ NLMISC_COMMAND(forceJournalUpdate,"force mission journal update","getMissions()[i]->updateUsersJournalEntry(); } } - for (uint i = 0; i < MaxGuildMissionCount; i++) + CGuild * guild = CGuildManager::getInstance()->getGuildFromId( user->getGuildId() ); + if (guild) + { + for ( uint i = 0; i < guild->getMissions().size(); i++ ) + { + guild->getMissions()[i]->updateUsersJournalEntry(); + } + } + /*for (uint i = 0; i < MaxGuildMissionCount; i++) { /// todo guild mission - } + }*/ return true; } // missionProgress //