Changed: #1304: Debug for the guild missions. Now it works !

--HG--
branch : gsoc2011-guildmissions
This commit is contained in:
Fabien_HENON 2011-08-04 17:04:49 +02:00
parent 1f057afe91
commit ff5da0aa22
8 changed files with 76 additions and 17 deletions

View file

@ -707,6 +707,7 @@
<PARAMETER NAME="name" TYPE="string" VISIBLE="true" AUTONAME="spawn_mission : $mission_name$ : $giver_name$"/>
<PARAMETER NAME="mission_name" TYPE="string" VISIBLE="true"/>
<PARAMETER NAME="giver_name" TYPE="string" VISIBLE="true"/>
<PARAMETER NAME="guild" TYPE="boolean" VISIBLE="true" />
</PRIMITIVE>
<PRIMITIVE CLASS_NAME="encyclo_unlock" TYPE="node" AUTO_INIT="false" DELETABLE="true" NUMBERIZE="false">

View file

@ -795,7 +795,7 @@ bool CGuild::processGuildMissionStepEvent(std::list< CMissionEvent*> & eventList
return false;
}
// I don't know if i should pass _EId to this function
CMissionEvent::TResult result = mission->processEvent( TheDataset.getDataSetRow( _EId) ,eventList,stepIndex );
CMissionEvent::TResult result = mission->processEvent(TheDataset.getDataSetRow(getHighestGradeOnlineUser()) /*TheDataset.getDataSetRow( _EId)*/ ,eventList,stepIndex );
if ( result == CMissionEvent::Nothing )
return false;
else if ( result == CMissionEvent::MissionFailed )

View file

@ -4053,15 +4053,16 @@ protected:
TAIAlias Mission;
TAIAlias NPCOwner; // NPC giver the mission have to be attached at spawn time
bool Guild;
protected:
bool buildAction ( uint32 line, const std::vector< std::string > & script, CMissionGlobalParsingData & globalData, CMissionSpecificParsingData & missionData)
{
_SourceLine = line;
if ( script.size() != 3 )
if ( script.size() != 3 && script.size() != 4)
{
MISLOGSYNTAXERROR("<mission_name> : <giver_name>");
MISLOGSYNTAXERROR("<mission_name> : <giver_name> [: guild]");
return false;
}
string name = CMissionParser::getNoBlankString( script[1] );
@ -4094,6 +4095,17 @@ protected:
if (vRet.size() > 0)
NPCOwner = vRet[0];
// We check for the guild option
Guild = false;
for (std::vector< std::string >::const_iterator it = script.begin(); it != script.end(); ++it)
{
if (CMissionParser::getNoBlankString(*it) == "guild")
{
Guild = true;
break;
}
}
return true;
}
@ -4104,13 +4116,13 @@ protected:
{
CAIAliasTranslator::getInstance()->getNPCNameFromAlias(instance->getGiver(), sDebugBotName);
nlassert(instance);
CMissionEventAddMission * event = new CMissionEventAddMission( instance->getGiver(), Mission, mainMission );
CMissionEventAddMission * event = new CMissionEventAddMission( instance->getGiver(), Mission, mainMission, Guild );
eventList.push_back( event );
}
else
{
CAIAliasTranslator::getInstance()->getNPCNameFromAlias(NPCOwner, sDebugBotName);
CMissionEventAddMission * event = new CMissionEventAddMission( NPCOwner, Mission, mainMission );
CMissionEventAddMission * event = new CMissionEventAddMission( NPCOwner, Mission, mainMission, Guild );
eventList.push_back( event );
}
LOGMISSIONACTION("spawn_mission bot:" + sDebugBotName + " newmiss:" + CPrimitivesParser::aliasToString(Mission)

View file

@ -416,11 +416,12 @@ protected:
class CMissionEventAddMission: public CMissionEvent
{
public:
CMissionEventAddMission( TAIAlias giver, TAIAlias mission, TAIAlias mainMission )
:CMissionEvent(AddMission, TDataSetRow()) ,Giver(giver),Mission(mission),MainMission(mainMission) {}
CMissionEventAddMission( TAIAlias giver, TAIAlias mission, TAIAlias mainMission, bool guild )
:CMissionEvent(AddMission, TDataSetRow()) ,Giver(giver),Mission(mission),MainMission(mainMission), Guild(guild) {}
TAIAlias Mission;
TAIAlias Giver;
TAIAlias MainMission;
bool Guild;
protected:
friend class CMissionEvent;
bool buildFromScript( const std::vector< std::string > & script ,NLMISC::CLog& log){return false;}

View file

@ -32,7 +32,7 @@ public:
CMissionGuild() : _Chained(false) { }
inline void setGuild( uint16 guildId );
inline void setGuild( uint32 guildId );
/// override
void updateUsersJournalEntry();
/// override
@ -59,7 +59,7 @@ private:
bool _Chained;
};
void CMissionGuild::setGuild( uint16 guildId )
void CMissionGuild::setGuild( uint32 guildId )
{
_GuildId = guildId;
}

View file

@ -1165,7 +1165,17 @@ class CMissionStepDoMissions : public IMissionStepTemplate
for ( uint i = 0; i < subs.size(); i++ )
{
std::vector< std::string > params;
NLMISC::splitString( subs[i]," \t", params );
//NLMISC::splitString( subs[i]," \t", params );
subs[i] = CMissionParser::getNoBlankString(subs[i]);
std::size_t pos = subs[i].find_first_of(" \t");
std::string str = subs[i].substr(0, pos);
params.push_back(str);
if (pos != std::string::npos)
str = subs[i].substr(pos + 1);
else
str = "";
params.push_back(str);
//std::size_t pos = _Missions[i].find_first_of(" \t");
_Missions[i].Mission = CMissionParser::getNoBlankString( params[0] );
if (params.size() > 1)
NLMISC::fromString(params[1], _Missions[i].NbNeedCompletion);

View file

@ -11641,11 +11641,33 @@ bool CCharacter::processMissionEventList( std::list< CMissionEvent* > & eventLis
TAIAlias mission = eventSpe.Mission;
TAIAlias giver = eventSpe.Giver;
TAIAlias mainMission = eventSpe.MainMission;
bool missionForGuild = eventSpe.Guild;
// add mission event are always allocated on heap
delete ( CMissionEvent *) ( eventList.front() );
eventList.pop_front();
CMissionManager::getInstance()->instanciateMission(this, mission, giver ,eventList, mainMission);
// If the mission is not for guild members we just instanciate it
if (!missionForGuild)
CMissionManager::getInstance()->instanciateMission(this, mission, giver ,eventList, mainMission);
else
{
// We find the guild and each guild members and we instanciate the mission for them
if (guild)
{
for ( std::map<EGSPD::TCharacterId, EGSPD::CGuildMemberPD*>::iterator it = guild->getMembersBegin();
it != guild->getMembersEnd();++it )
{
CCharacter * guildUser = PlayerManager.getChar( it->first );
if ( !guildUser )
{
nlwarning( "<MISSIONS>cant find user %s", it->first.toString().c_str() );
continue;
}
CMissionManager::getInstance()->instanciateMission(guildUser, mission, giver ,eventList, mainMission);
}
}
}
}
// event may have been processed during instanciateMission
if ( eventList.empty() )
@ -11667,7 +11689,7 @@ bool CCharacter::processMissionEventList( std::list< CMissionEvent* > & eventLis
}
// THIRD - Check with guild missions (if event not already processed and char belongs to a guild)
if (!eventProcessed && (event.Restriction != CMissionEvent::NoGroup))
if (!eventProcessed)// && (event.Restriction != CMissionEvent::NoGroup))
{
if (guild != NULL)
eventProcessed = guild->processGuildMissionEvent(eventList, alias);

View file

@ -254,6 +254,7 @@ class CActionSpawnMission : public IStepContent
protected:
string _MissionName;
string _GiverName;
bool _Guild;
private:
void getPredefParam(uint32 &numEntry, CPhrase::TPredefParams &predef)
{
@ -268,17 +269,29 @@ public:
if (_GiverName.empty())
{
throw EParseException(prim, "giver_name is empty !");
}
}
_Guild = md.getProperty(prim, "guild", false, true) == "true";
// Check: if _Guild is true then check if we are in a guild mission
if (_Guild && !md.isGuildMission())
{
string err = toString("primitive(%s): 'guild' option true 1 for non guild mission.", prim->getName().c_str());
throw EParseException(prim, err.c_str());
}
}
string genCode(CMissionData &md)
{
string ret = "";
if (!_MissionName.empty())
return "spawn_mission : " + _MissionName + " : " + _GiverName + NL;
else
return string();
{
ret = "spawn_mission : " + _MissionName + " : " + _GiverName;
if (_Guild)
ret += " : guild";
ret += NL;
}
return ret;
}
};
REGISTER_STEP_CONTENT(CActionSpawnMission, "spawn_mission");