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

This commit is contained in:
Fabien_HENON 2011-08-04 17:04:49 +02:00
parent 4f18078b20
commit 6326967cd9
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="name" TYPE="string" VISIBLE="true" AUTONAME="spawn_mission : $mission_name$ : $giver_name$"/>
<PARAMETER NAME="mission_name" TYPE="string" VISIBLE="true"/> <PARAMETER NAME="mission_name" TYPE="string" VISIBLE="true"/>
<PARAMETER NAME="giver_name" TYPE="string" VISIBLE="true"/> <PARAMETER NAME="giver_name" TYPE="string" VISIBLE="true"/>
<PARAMETER NAME="guild" TYPE="boolean" VISIBLE="true" />
</PRIMITIVE> </PRIMITIVE>
<PRIMITIVE CLASS_NAME="encyclo_unlock" TYPE="node" AUTO_INIT="false" DELETABLE="true" NUMBERIZE="false"> <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; return false;
} }
// I don't know if i should pass _EId to this function // 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 ) if ( result == CMissionEvent::Nothing )
return false; return false;
else if ( result == CMissionEvent::MissionFailed ) else if ( result == CMissionEvent::MissionFailed )

View file

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

View file

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

View file

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

View file

@ -1165,7 +1165,17 @@ class CMissionStepDoMissions : public IMissionStepTemplate
for ( uint i = 0; i < subs.size(); i++ ) for ( uint i = 0; i < subs.size(); i++ )
{ {
std::vector< std::string > params; 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] ); _Missions[i].Mission = CMissionParser::getNoBlankString( params[0] );
if (params.size() > 1) if (params.size() > 1)
NLMISC::fromString(params[1], _Missions[i].NbNeedCompletion); 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 mission = eventSpe.Mission;
TAIAlias giver = eventSpe.Giver; TAIAlias giver = eventSpe.Giver;
TAIAlias mainMission = eventSpe.MainMission; TAIAlias mainMission = eventSpe.MainMission;
bool missionForGuild = eventSpe.Guild;
// add mission event are always allocated on heap // add mission event are always allocated on heap
delete ( CMissionEvent *) ( eventList.front() ); delete ( CMissionEvent *) ( eventList.front() );
eventList.pop_front(); eventList.pop_front();
// If the mission is not for guild members we just instanciate it
if (!missionForGuild)
CMissionManager::getInstance()->instanciateMission(this, mission, giver ,eventList, mainMission); 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 // event may have been processed during instanciateMission
if ( eventList.empty() ) 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) // 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) if (guild != NULL)
eventProcessed = guild->processGuildMissionEvent(eventList, alias); eventProcessed = guild->processGuildMissionEvent(eventList, alias);

View file

@ -254,6 +254,7 @@ class CActionSpawnMission : public IStepContent
protected: protected:
string _MissionName; string _MissionName;
string _GiverName; string _GiverName;
bool _Guild;
private: private:
void getPredefParam(uint32 &numEntry, CPhrase::TPredefParams &predef) void getPredefParam(uint32 &numEntry, CPhrase::TPredefParams &predef)
{ {
@ -269,16 +270,28 @@ public:
{ {
throw EParseException(prim, "giver_name is 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 genCode(CMissionData &md)
{ {
string ret = "";
if (!_MissionName.empty()) if (!_MissionName.empty())
return "spawn_mission : " + _MissionName + " : " + _GiverName + NL; {
else ret = "spawn_mission : " + _MissionName + " : " + _GiverName;
return string(); if (_Guild)
ret += " : guild";
ret += NL;
}
return ret;
} }
}; };
REGISTER_STEP_CONTENT(CActionSpawnMission, "spawn_mission"); REGISTER_STEP_CONTENT(CActionSpawnMission, "spawn_mission");