From 347917847635e5abb240e53f9fbf7dc3ad8f2561 Mon Sep 17 00:00:00 2001 From: Fabien_HENON Date: Mon, 20 Jun 2011 15:15:07 +0200 Subject: [PATCH] Changed: #1304: Instanciation of guild missions. --- .../guild_manager/guild.h | 1 + .../guild_manager/guild_member_module.h | 6 ++ .../guild_manager/guild_officer_module.h | 8 +++ .../mission_manager/mission_guild.h | 5 ++ .../mission_manager/mission_manager.cpp | 60 +++++++++++++++---- 5 files changed, 69 insertions(+), 11 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 3f3b04eb6..49b02e93c 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 @@ -184,6 +184,7 @@ public: { // To Do } + void addMission(CMissionGuild* guildMission) {} //@} /// inventory management diff --git a/code/ryzom/server/src/entities_game_service/guild_manager/guild_member_module.h b/code/ryzom/server/src/entities_game_service/guild_manager/guild_member_module.h index 4447e356f..46dee0f96 100644 --- a/code/ryzom/server/src/entities_game_service/guild_manager/guild_member_module.h +++ b/code/ryzom/server/src/entities_game_service/guild_manager/guild_member_module.h @@ -99,6 +99,12 @@ public: /// user wanna pick a mission CMissionGuild * pickMission( TAIAlias alias ); + // Function to check if the member can pick a mission. By default only Officer and above can pick a guild mission + virtual bool canPickMission(TAIAlias alias) + { + return false; + } + /// set the version of last sent info of items in guild inventory void setLastSentInfoVersion(uint32 slot, uint8 infoVersion) { diff --git a/code/ryzom/server/src/entities_game_service/guild_manager/guild_officer_module.h b/code/ryzom/server/src/entities_game_service/guild_manager/guild_officer_module.h index 7d6f49096..e31885300 100644 --- a/code/ryzom/server/src/entities_game_service/guild_manager/guild_officer_module.h +++ b/code/ryzom/server/src/entities_game_service/guild_manager/guild_officer_module.h @@ -34,6 +34,14 @@ public: :CGuildMemberModule(proxy,guildMember){} virtual bool canAffectGrade(EGSPD::CGuildGrade::TGuildGrade grade)const; virtual bool canInvite()const; + + // Function to check if the member can pick a mission. + // By default only Officers and above can pick a guild mission. + // So we don't need to implement this function for the other grades + virtual bool canPickMission(TAIAlias alias) + { + return true; + } }; ; diff --git a/code/ryzom/server/src/entities_game_service/mission_manager/mission_guild.h b/code/ryzom/server/src/entities_game_service/mission_manager/mission_guild.h index e0c65f2c2..76cd0cb6a 100644 --- a/code/ryzom/server/src/entities_game_service/mission_manager/mission_guild.h +++ b/code/ryzom/server/src/entities_game_service/mission_manager/mission_guild.h @@ -32,6 +32,7 @@ public: CMissionGuild() : _Chained(false) { } + inline void setGuild( uint16 guildId ); /// override void updateUsersJournalEntry(); /// override @@ -58,6 +59,10 @@ private: bool _Chained; }; +void CMissionGuild::setGuild( uint16 guildId ) +{ + _GuildId = guildId; +} #endif // RY_MISSION_GUILD_H 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 55a08ef4f..057412068 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 @@ -836,29 +836,68 @@ void CMissionManager::instanciateMission(CCharacter* user,TAIAlias alias, TAIAl } else if ( templ->Type == MISSION_DESC::Guild ) { - /// todo guild mission + /// Check to see if we can pick the mission CGuildMemberModule * module; if ( !user->getModuleParent().getModule( module ) ) { MISDBG("%s user not in a guild", sDebugPrefix.c_str()); return; } - inst = module->pickMission( templ->Alias ); - if (!inst) + /* /// This is already checked in the prerequisites + if (!module->pickMission( templ->Alias )) + { + /// Todo : error message for the member return; + }*/ + + CGuild * guild = CGuildManager::getInstance()->getGuildFromId( user->getGuildId() ); + if (!guild) + { + nlwarning( "cant find guild ID : %d", _GuildId ); + return; + } + if ( !templ->Tags.NoList && guild->getMissions().size() >= MaxGuildMissionCount) + { + CCharacter::sendDynamicSystemMessage(user->getId(), "MISSION_MAX_GUILD_REACHED" ); + return; + } + + CMissionGuild * guildMission = EGS_PD_CAST( EGSPD::CMissionGuildPD::create( templ->Alias ) ); + if ( !guildMission ) + { + MISDBG("%s could not create guild mission", sDebugPrefix.c_str()); + return; + } + guildMission->onCreation( giver ); + guildMission->setGuild(user->getGuildId()); + + // Find a suitable client index (for non-invisible missions) + if ( templ->Tags.NoList == false ) + { + uint8 idx = 0; + for ( uint i = MaxGroupMissionCount; i < MaxGroupMissionCount + MaxGuildMissionCount; i++ ) + { + if ( ! CBankAccessor_PLR::getGROUP().getMISSIONS().getArray(i).getTITLE(user->_PropertyDatabase)) + { + idx = i; + break; + } + } + guildMission->setClientIndex( idx ); + } + + // Add mission + guild->addMission( guildMission ); + inst = guildMission; /// /!\ 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 - teamMission->initBasics( giver ); - soloMission->setTeam( user->getTeamId() ); + /*//teamMission->initBasics( giver ); + //soloMission->setTeam( user->getTeamId() ); CGuild * guild = user->getGuild(); if ( guild ) { - mission->getguild if ( guild->getMissions().size() >= MaxGuildMissionCount) { CCharacter::sendDynamicSystemMessage(user->getId(), "MISSION_MAX_GUILD_REACHED" ); @@ -884,8 +923,7 @@ void CMissionManager::instanciateMission(CCharacter* user,TAIAlias alias, TAIAl else { - } - */ + }*/ } else {