forked from mirror/openmw-tes3mp
some cleanup
This commit is contained in:
parent
401903c9ce
commit
0f4f91605a
3 changed files with 20 additions and 14 deletions
|
@ -2,6 +2,7 @@
|
|||
#include "dialoguemanagerimp.hpp"
|
||||
|
||||
#include <cctype>
|
||||
#include <cstdlib>
|
||||
#include <algorithm>
|
||||
#include <iterator>
|
||||
|
||||
|
@ -251,11 +252,11 @@ namespace MWDialogue
|
|||
|
||||
MWGui::DialogueWindow* win = MWBase::Environment::get().getWindowManager()->getDialogueWindow();
|
||||
|
||||
std::vector<const ESM::DialInfo*> infos;
|
||||
filter.search (infos, dialogue, true, true);
|
||||
std::vector<const ESM::DialInfo *> infos = filter.list (dialogue, true, true);
|
||||
|
||||
if (!infos.empty())
|
||||
{
|
||||
const ESM::DialInfo* info = infos[rand() % infos.size()];
|
||||
const ESM::DialInfo* info = infos[std::rand() % infos.size()];
|
||||
|
||||
parseText (info->mResponse);
|
||||
|
||||
|
|
|
@ -561,8 +561,7 @@ MWDialogue::Filter::Filter (const MWWorld::Ptr& actor, int choice, bool talkedTo
|
|||
|
||||
const ESM::DialInfo* MWDialogue::Filter::search (const ESM::Dialogue& dialogue, const bool fallbackToInfoRefusal) const
|
||||
{
|
||||
std::vector<const ESM::DialInfo*> suitableInfos;
|
||||
search(suitableInfos, dialogue, fallbackToInfoRefusal, false);
|
||||
std::vector<const ESM::DialInfo *> suitableInfos = list (dialogue, fallbackToInfoRefusal, false);
|
||||
|
||||
if (suitableInfos.empty())
|
||||
return NULL;
|
||||
|
@ -570,10 +569,10 @@ const ESM::DialInfo* MWDialogue::Filter::search (const ESM::Dialogue& dialogue,
|
|||
return suitableInfos[0];
|
||||
}
|
||||
|
||||
void MWDialogue::Filter::search (std::vector<const ESM::DialInfo*>& suitableInfos, const ESM::Dialogue& dialogue,
|
||||
const bool fallbackToInfoRefusal, bool searchAll) const
|
||||
std::vector<const ESM::DialInfo *> MWDialogue::Filter::list (const ESM::Dialogue& dialogue,
|
||||
bool fallbackToInfoRefusal, bool searchAll) const
|
||||
{
|
||||
suitableInfos.clear();
|
||||
std::vector<const ESM::DialInfo *> infos;
|
||||
|
||||
bool infoRefusal = false;
|
||||
|
||||
|
@ -584,16 +583,16 @@ void MWDialogue::Filter::search (std::vector<const ESM::DialInfo*>& suitableInfo
|
|||
if (testActor (*iter) && testPlayer (*iter) && testSelectStructs (*iter))
|
||||
{
|
||||
if (testDisposition (*iter)) {
|
||||
suitableInfos.push_back(&*iter);
|
||||
infos.push_back(&*iter);
|
||||
if (!searchAll)
|
||||
return;
|
||||
break;
|
||||
}
|
||||
else
|
||||
infoRefusal = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (suitableInfos.empty() && infoRefusal && fallbackToInfoRefusal)
|
||||
if (infos.empty() && infoRefusal && fallbackToInfoRefusal)
|
||||
{
|
||||
// No response is valid because of low NPC disposition,
|
||||
// search a response in the topic "Info Refusal"
|
||||
|
@ -606,11 +605,13 @@ void MWDialogue::Filter::search (std::vector<const ESM::DialInfo*>& suitableInfo
|
|||
for (std::vector<ESM::DialInfo>::const_iterator iter = infoRefusalDialogue.mInfo.begin();
|
||||
iter!=infoRefusalDialogue.mInfo.end(); ++iter)
|
||||
if (testActor (*iter) && testPlayer (*iter) && testSelectStructs (*iter) && testDisposition(*iter)) {
|
||||
suitableInfos.push_back(&*iter);
|
||||
infos.push_back(&*iter);
|
||||
if (!searchAll)
|
||||
return;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return infos;
|
||||
}
|
||||
|
||||
bool MWDialogue::Filter::responseAvailable (const ESM::Dialogue& dialogue) const
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#ifndef GAME_MWDIALOGUE_FILTER_H
|
||||
#define GAME_MWDIALOGUE_FILTER_H
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
|
||||
namespace ESM
|
||||
|
@ -51,7 +53,9 @@ namespace MWDialogue
|
|||
|
||||
Filter (const MWWorld::Ptr& actor, int choice, bool talkedToPlayer);
|
||||
|
||||
void search (std::vector<const ESM::DialInfo*>& suitableInfos, const ESM::Dialogue& dialogue, const bool fallbackToInfoRefusal, bool searchAll) const;
|
||||
std::vector<const ESM::DialInfo *> list (const ESM::Dialogue& dialogue,
|
||||
bool fallbackToInfoRefusal, bool searchAll) const;
|
||||
|
||||
const ESM::DialInfo* search (const ESM::Dialogue& dialogue, const bool fallbackToInfoRefusal) const;
|
||||
///< Get a matching response for the requested dialogue.
|
||||
/// Redirect to "Info Refusal" topic if a response fulfills all conditions but disposition.
|
||||
|
|
Loading…
Reference in a new issue