mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-03-03 21:49:41 +00:00
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 "dialoguemanagerimp.hpp"
|
||||||
|
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
|
#include <cstdlib>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
|
|
||||||
|
@ -251,11 +252,11 @@ namespace MWDialogue
|
||||||
|
|
||||||
MWGui::DialogueWindow* win = MWBase::Environment::get().getWindowManager()->getDialogueWindow();
|
MWGui::DialogueWindow* win = MWBase::Environment::get().getWindowManager()->getDialogueWindow();
|
||||||
|
|
||||||
std::vector<const ESM::DialInfo*> infos;
|
std::vector<const ESM::DialInfo *> infos = filter.list (dialogue, true, true);
|
||||||
filter.search (infos, dialogue, true, true);
|
|
||||||
if (!infos.empty())
|
if (!infos.empty())
|
||||||
{
|
{
|
||||||
const ESM::DialInfo* info = infos[rand() % infos.size()];
|
const ESM::DialInfo* info = infos[std::rand() % infos.size()];
|
||||||
|
|
||||||
parseText (info->mResponse);
|
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
|
const ESM::DialInfo* MWDialogue::Filter::search (const ESM::Dialogue& dialogue, const bool fallbackToInfoRefusal) const
|
||||||
{
|
{
|
||||||
std::vector<const ESM::DialInfo*> suitableInfos;
|
std::vector<const ESM::DialInfo *> suitableInfos = list (dialogue, fallbackToInfoRefusal, false);
|
||||||
search(suitableInfos, dialogue, fallbackToInfoRefusal, false);
|
|
||||||
|
|
||||||
if (suitableInfos.empty())
|
if (suitableInfos.empty())
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -570,10 +569,10 @@ const ESM::DialInfo* MWDialogue::Filter::search (const ESM::Dialogue& dialogue,
|
||||||
return suitableInfos[0];
|
return suitableInfos[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
void MWDialogue::Filter::search (std::vector<const ESM::DialInfo*>& suitableInfos, const ESM::Dialogue& dialogue,
|
std::vector<const ESM::DialInfo *> MWDialogue::Filter::list (const ESM::Dialogue& dialogue,
|
||||||
const bool fallbackToInfoRefusal, bool searchAll) const
|
bool fallbackToInfoRefusal, bool searchAll) const
|
||||||
{
|
{
|
||||||
suitableInfos.clear();
|
std::vector<const ESM::DialInfo *> infos;
|
||||||
|
|
||||||
bool infoRefusal = false;
|
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 (testActor (*iter) && testPlayer (*iter) && testSelectStructs (*iter))
|
||||||
{
|
{
|
||||||
if (testDisposition (*iter)) {
|
if (testDisposition (*iter)) {
|
||||||
suitableInfos.push_back(&*iter);
|
infos.push_back(&*iter);
|
||||||
if (!searchAll)
|
if (!searchAll)
|
||||||
return;
|
break;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
infoRefusal = true;
|
infoRefusal = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (suitableInfos.empty() && infoRefusal && fallbackToInfoRefusal)
|
if (infos.empty() && infoRefusal && fallbackToInfoRefusal)
|
||||||
{
|
{
|
||||||
// No response is valid because of low NPC disposition,
|
// No response is valid because of low NPC disposition,
|
||||||
// search a response in the topic "Info Refusal"
|
// 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();
|
for (std::vector<ESM::DialInfo>::const_iterator iter = infoRefusalDialogue.mInfo.begin();
|
||||||
iter!=infoRefusalDialogue.mInfo.end(); ++iter)
|
iter!=infoRefusalDialogue.mInfo.end(); ++iter)
|
||||||
if (testActor (*iter) && testPlayer (*iter) && testSelectStructs (*iter) && testDisposition(*iter)) {
|
if (testActor (*iter) && testPlayer (*iter) && testSelectStructs (*iter) && testDisposition(*iter)) {
|
||||||
suitableInfos.push_back(&*iter);
|
infos.push_back(&*iter);
|
||||||
if (!searchAll)
|
if (!searchAll)
|
||||||
return;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return infos;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MWDialogue::Filter::responseAvailable (const ESM::Dialogue& dialogue) const
|
bool MWDialogue::Filter::responseAvailable (const ESM::Dialogue& dialogue) const
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
#ifndef GAME_MWDIALOGUE_FILTER_H
|
#ifndef GAME_MWDIALOGUE_FILTER_H
|
||||||
#define GAME_MWDIALOGUE_FILTER_H
|
#define GAME_MWDIALOGUE_FILTER_H
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "../mwworld/ptr.hpp"
|
#include "../mwworld/ptr.hpp"
|
||||||
|
|
||||||
namespace ESM
|
namespace ESM
|
||||||
|
@ -51,7 +53,9 @@ namespace MWDialogue
|
||||||
|
|
||||||
Filter (const MWWorld::Ptr& actor, int choice, bool talkedToPlayer);
|
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;
|
const ESM::DialInfo* search (const ESM::Dialogue& dialogue, const bool fallbackToInfoRefusal) const;
|
||||||
///< Get a matching response for the requested dialogue.
|
///< Get a matching response for the requested dialogue.
|
||||||
/// Redirect to "Info Refusal" topic if a response fulfills all conditions but disposition.
|
/// Redirect to "Info Refusal" topic if a response fulfills all conditions but disposition.
|
||||||
|
|
Loading…
Reference in a new issue