Merge branch 'ark'

feature/prepare-cross-merge
Ulukyn 5 years ago committed by kaetemi
parent f764a0e6d9
commit 085cead1a1
No known key found for this signature in database
GPG Key ID: 9873C4D40BB479BC

@ -1405,6 +1405,28 @@ void CMissionManager::removeAllUserDynChat(CCharacter * user)
user->processMissionEvent(event,aliases[i] ); user->processMissionEvent(event,aliases[i] );
} }
void CMissionManager::processMissionsEventEndDynChat(CCharacter * user)
{
// we first close all the concerned dyn chat interface on the client,then send EndDynchat event and finally remove the concerned entries from the map
// we have to do it in three passes because processMissionEvent can remove dyn chat entries. And we'd better avoid dereferencement on invalid iterators...
nlassert(user);
vector<TAIAlias> aliases;
// close all interfaces
CHashMultiMap<TDataSetRow,CDynChat,TDataSetRow::CHashCode>::iterator it = _DynChats.find( user->getEntityRowId() );
for (; it!= _DynChats.end() && (*it).first == user->getEntityRowId(); ++it )
{
aliases.push_back((*it).second.Mission->getTemplateId());
}
// For each concerned mission, send an end dyn chat event to the player, specifying the mission
// This must be after _DynChats.erase(user->getEntityRowId()), otherwise the event (e.g. jump
// back) can trigger a openDynChat() on the same bot that would lead to a reentrance bug.
CMissionEventEndDynChat event;
const uint eventCount = (uint)aliases.size();
for ( uint i = 0; i < eventCount; ++i )
user->processMissionEvent(event,aliases[i] );
}
void CMissionManager::removeMissionDynChat(CCharacter * user, CMission * instance) void CMissionManager::removeMissionDynChat(CCharacter * user, CMission * instance)
{ {
nlassert(user); nlassert(user);
@ -1495,6 +1517,7 @@ void CMissionManager::dynChatChoice( CCharacter * user, const TDataSetRow & botR
uint i = 0; uint i = 0;
uint nbJumpPoints = (uint)templ->JumpPoints.size(); uint nbJumpPoints = (uint)templ->JumpPoints.size();
bool updateJournal = false; bool updateJournal = false;
nlinfo("nbJumpPoints = %d", nbJumpPoints);
for (; i < nbJumpPoints; i++ ) for (; i < nbJumpPoints; i++ )
{ {
if ( templ->JumpPoints[i].Name == jump ) if ( templ->JumpPoints[i].Name == jump )
@ -1503,6 +1526,7 @@ void CMissionManager::dynChatChoice( CCharacter * user, const TDataSetRow & botR
closeDynChat( user, botRow ); closeDynChat( user, botRow );
std::list< CMissionEvent * > eventList; std::list< CMissionEvent * > eventList;
nlinfo("Jump to %d", i);
inst->jump( templ->JumpPoints[i].Step,templ->JumpPoints[i].Action,eventList ); inst->jump( templ->JumpPoints[i].Step,templ->JumpPoints[i].Action,eventList );
// Send to AIS (to stop the bot). Important: there must be the same number of items pushed in DynChatEnd that in DynChatStart for the bot to resume. // Send to AIS (to stop the bot). Important: there must be the same number of items pushed in DynChatEnd that in DynChatStart for the bot to resume.

@ -4153,8 +4153,23 @@ NLMISC_COMMAND(startMoveBot,"start move bot or previous stopped bot","<uid|*> [<
CharacterBotChatBeginEnd.BotChatEnd.push_back(TargetRowId); CharacterBotChatBeginEnd.BotChatEnd.push_back(TargetRowId);
log.displayNL("OK"); log.displayNL("OK");
return true;
} }
NLMISC_COMMAND(closeDynChat, "close DynChat", "<uid> <process missions?>")
{
if (args.size() < 1) return false;
GET_ACTIVE_CHARACTER
bool processMissions = true;
if (args.size() >= 2 && (args[1] == "false" || args[1] == "0"))
processMissions = false;
c->endBotChat(false, false, processMissions);
return true;
}
NLMISC_COMMAND(manageBuilding, "Manage a building", "<uid> <action>") NLMISC_COMMAND(manageBuilding, "Manage a building", "<uid> <action>")
{ {

@ -12206,7 +12206,7 @@ CCreature* CCharacter::startBotChat(BOTCHATTYPE::TBotChatFlags chatType)
// endBotChat // endBotChat
// //
//----------------------------------------------- //-----------------------------------------------
void CCharacter::endBotChat(bool newBotChat, bool closeDynChat) void CCharacter::endBotChat(bool newBotChat, bool closeDynChat, bool processMissions)
{ {
_TradePagesToUpdate.clear(); _TradePagesToUpdate.clear();
@ -12243,6 +12243,8 @@ void CCharacter::endBotChat(bool newBotChat, bool closeDynChat)
if (closeDynChat) if (closeDynChat)
CMissionManager::getInstance()->removeAllUserDynChat(this); CMissionManager::getInstance()->removeAllUserDynChat(this);
else if (processMissions)
CMissionManager::getInstance()->processMissionsEventEndDynChat(this);
} }
// Inform AI about bot chat end // Inform AI about bot chat end

@ -1175,7 +1175,7 @@ public:
/// end the bot chat. newBotChat must be set to true if the chat is canceled because of another bot chat. /// end the bot chat. newBotChat must be set to true if the chat is canceled because of another bot chat.
/// closeDynChat must be true to close the current dynChat /// closeDynChat must be true to close the current dynChat
void endBotChat(bool newBotChat = false, bool closeDynChat = false); void endBotChat(bool newBotChat = false, bool closeDynChat = false, bool processMissions = false);
/// return the current bot chat type /// return the current bot chat type
uint8 getBotChatType() const; uint8 getBotChatType() const;

Loading…
Cancel
Save