From a7f4bfa718411811d3c861908e3f12831fde5d74 Mon Sep 17 00:00:00 2001 From: Fabien_HENON Date: Mon, 20 Jun 2011 16:08:12 +0200 Subject: [PATCH] Changed: #1304: Add guild missions prerequisites. --HG-- branch : gsoc2011-guildmissions --- .../guild_manager/guild.h | 2 + .../mission_manager/mission_manager.cpp | 3 +- .../mission_manager/mission_template.cpp | 102 ++++++++++++++---- 3 files changed, 86 insertions(+), 21 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 49b02e93c..ecedbf9ee 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 @@ -182,9 +182,11 @@ public: ///\return the mission inline std::vector & getMissions() { + return std::vector(); // To Do } void addMission(CMissionGuild* guildMission) {} + bool isMissionSuccessfull(TAIAlias alias) { return false; } //@} /// inventory management 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 057412068..ca5d4bba0 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 @@ -44,6 +44,7 @@ #include "egs_utils.h" #include "egs_pd.h" #include "guild_manager/guild_member_module.h" +#include "guild_manager/guild_manager.h" #include "building_manager/building_manager.h" #include "building_manager/room_instance.h" #include "zone_manager.h" @@ -853,7 +854,7 @@ void CMissionManager::instanciateMission(CCharacter* user,TAIAlias alias, TAIAl CGuild * guild = CGuildManager::getInstance()->getGuildFromId( user->getGuildId() ); if (!guild) { - nlwarning( "cant find guild ID : %d", _GuildId ); + nlwarning( "cant find guild ID : %d", user->getGuildId() ); return; } if ( !templ->Tags.NoList && guild->getMissions().size() >= MaxGuildMissionCount) diff --git a/code/ryzom/server/src/entities_game_service/mission_manager/mission_template.cpp b/code/ryzom/server/src/entities_game_service/mission_manager/mission_template.cpp index dfd516b45..af0686f1e 100644 --- a/code/ryzom/server/src/entities_game_service/mission_manager/mission_template.cpp +++ b/code/ryzom/server/src/entities_game_service/mission_manager/mission_template.cpp @@ -1307,21 +1307,57 @@ uint32 CMissionTemplate::testPrerequisits( CCharacter * user, CPrerequisitInfos else if ( Type == MISSION_DESC::Guild ) { /// todo guild mission - /* - CGuild * guild = user->getGuild(); + + CGuild * guild = CGuildManager::getInstance()->getGuildFromId( user->getGuildId() ); if ( guild == NULL ) { MISDBG("No guild"); return MISSION_DESC::PreReqFail; + + /*if (logOnFail) + MISDBG("%s No guild", sDebugPrefix.c_str()); + + if (!fillPrereqInfos) + return MISSION_DESC::PreReqFail; + + prereqDesc.Description = STRING_MANAGER::sendStringToClient(user->getEntityRowId(), "MISSION_PREREQ_TEAM", TVectorParamCheck()); + prereqDesc.IsMandatory = true; + prereqDesc.Validated = false; + prereqInfos.Prerequisits.push_back(prereqDesc); + + addedPrereqTexts.insert("MISSION_PREREQ_TEAM"); + + returnValue = MISSION_DESC::PreReqFail; + logOnFail = false;*/ } // check if the mission is already picked for ( uint j = 0 ; j < guild->getMissions().size(); j++ ) { - if ( guild->getMissions()[j]->getTemplate()->Alias == alias ) + if ( guild->getMissions()[j]->getTemplateId() == alias || + guild->getMissions()[j]->getMainMissionTemplateId() == alias) { MISDBG("The guild already own this mission"); return MISSION_DESC::PreReqFail; + + /*if (logOnFail) + MISDBG("%s The guild already own this mission", sDebugPrefix.c_str()); + + if (!fillPrereqInfos) + return MISSION_DESC::PreReqFail; + + if (addedPrereqTexts.find("MISSION_PREREQ_ALREADY_DONE") == addedPrereqTexts.end()) + { + prereqDesc.Description = STRING_MANAGER::sendStringToClient(user->getEntityRowId(), "MISSION_PREREQ_ALREADY_DONE", TVectorParamCheck()); + prereqDesc.IsMandatory = true; + prereqDesc.Validated = false; + prereqInfos.Prerequisits.push_back(prereqDesc); + addedPrereqTexts.insert("MISSION_PREREQ_ALREADY_DONE"); + } + + returnValue = MISSION_DESC::PreReqFail; + logOnFail = false;*/ } + } // check non replayable missions if( !Tags.Replayable ) @@ -1329,11 +1365,29 @@ uint32 CMissionTemplate::testPrerequisits( CCharacter * user, CPrerequisitInfos if (guild->isMissionSuccessfull(alias)) // if ( std::find(guild->getSuccessfulMissions().begin(),guild->getSuccessfulMissions().end(), alias) != guild->getSuccessfulMissions().end() ) { - MISDBG("solo non replayable"); + MISDBG("mission non replayable"); return MISSION_DESC::PreReqFail; + + /*if (logOnFail) + MISDBG("%s Guild mission already done and not replayable", sDebugPrefix.c_str()); + + if (!fillPrereqInfos) + return MISSION_DESC::PreReqFailAlreadyDone; + + if (addedPrereqTexts.find("MISSION_PREREQ_ALREADY_DONE") == addedPrereqTexts.end()) + { + prereqDesc.Description = STRING_MANAGER::sendStringToClient(user->getEntityRowId(), "MISSION_PREREQ_ALREADY_DONE", TVectorParamCheck()); + prereqDesc.IsMandatory = true; + prereqDesc.Validated = false; + prereqInfos.Prerequisits.push_back(prereqDesc); + addedPrereqTexts.insert("MISSION_PREREQ_ALREADY_DONE"); + } + + returnValue = MISSION_DESC::PreReqFailAlreadyDone; + logOnFail = false;*/ } } - */ + } else { @@ -1412,7 +1466,7 @@ uint32 CMissionTemplate::testPrerequisits( CCharacter * user, CPrerequisitInfos if ( templ->Type == MISSION_DESC::Guild ) { /// todo guild mission - /* + CGuild* guild = CGuildManager::getInstance()->getGuildFromId( user->getGuildId() ); if ( ! guild ) { MISDBG("Require needed mission at line %u (guild mission but player has no guild)", Prerequisits.NeededMissions[i].Line); @@ -1420,7 +1474,7 @@ uint32 CMissionTemplate::testPrerequisits( CCharacter * user, CPrerequisitInfos } if (guild->isMissionSuccessfull(templ->Alias)) break; - */ + } else if ( templ->Type == MISSION_DESC::Solo ) { @@ -1473,15 +1527,14 @@ uint32 CMissionTemplate::testPrerequisits( CCharacter * user, CPrerequisitInfos else if ( templ->Type == MISSION_DESC::Guild ) { /// todo guild mission - /* + CGuild* guild = CGuildManager::getInstance()->getGuildFromId( user->getGuildId() ); if ( !guild ) break; if (!guild->isMissionSuccessfull(templ->Alias)) - - if (!guild || !guild->isMissionSuccessfull(templ->Alias)) - break; - */ + /*if (!guild || !guild->isMissionSuccessfull(templ->Alias)) + break;*/ + } else if ( templ->Type == MISSION_DESC::Solo ) { @@ -1537,8 +1590,8 @@ uint32 CMissionTemplate::testPrerequisits( CCharacter * user, CPrerequisitInfos { /// todo guild mission - /* - + + CGuild* guild = CGuildManager::getInstance()->getGuildFromId( user->getGuildId() ); if ( !guild ) { MISDBG("Require running mission at line %u (guild mission but player has no guild)", Prerequisits.RunningMissions[i].Line ); @@ -1548,12 +1601,12 @@ uint32 CMissionTemplate::testPrerequisits( CCharacter * user, CPrerequisitInfos for ( ; k < guild->getMissions().size(); k++ ) { - if ( guild->getMissions()[k]->getTemplate()->Alias == templ->Alias ) + if ( guild->getMissions()[k]->getTemplateId() == templ->Alias ) break; } if (k != guild->getMissions().size()) break; - */ + } else if ( templ->Type == MISSION_DESC::Solo ) { @@ -1651,20 +1704,20 @@ uint32 CMissionTemplate::testPrerequisits( CCharacter * user, CPrerequisitInfos { /// todo guild mission - /* - + + CGuild* guild = CGuildManager::getInstance()->getGuildFromId( user->getGuildId() ); if(!guild) break; uint k=0; for ( ; k < guild->getMissions().size(); k++ ) { - if ( guild->getMissions()[k]->getTemplate()->Alias == templ->Alias ) + if ( guild->getMissions()[k]->getTemplateId() == templ->Alias ) break; } if (k == guild->getMissions().size()) break; - */ + } else if ( templ->Type == MISSION_DESC::Solo ) { @@ -2041,6 +2094,15 @@ uint32 CMissionTemplate::testPrerequisits( CCharacter * user, CPrerequisitInfos if (!fillPrereqInfos) return MISSION_DESC::PreReqFail; + /*if (addedPrereqTexts.find("GUILD_BUILDING_BAD_GRADE") == addedPrereqTexts.end()) + { + prereqDesc.Description = STRING_MANAGER::sendStringToClient(user->getEntityRowId(), "GUILD_BUILDING_BAD_GRADE", TVectorParamCheck()); + prereqDesc.IsMandatory = true; + prereqDesc.Validated = false; + prereqInfos.Prerequisits.push_back(prereqDesc); + addedPrereqTexts.insert("GUILD_BUILDING_BAD_GRADE"); + }*/ + returnValue = MISSION_DESC::PreReqFail; logOnFail = false; }