diff options
| author | David Skoland <davidskoland@gmail.com> | 2017-01-27 01:24:58 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-01-27 01:24:58 +0100 |
| commit | d4ad200b612acb1ed2a74d057efc8c3cbfa07ad2 (patch) | |
| tree | a2b2dbee3b1a3102499b3cb5c6529e6f01655f74 /text_file_functions.cpp | |
| parent | ea9ba4526dc313a61682ec41b3b052019051545e (diff) | |
| parent | 9682087667e2de26e14406efde960b8c7f0c3c98 (diff) | |
Merge pull request #2 from OmniTroid/master
well
Diffstat (limited to 'text_file_functions.cpp')
| -rw-r--r-- | text_file_functions.cpp | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/text_file_functions.cpp b/text_file_functions.cpp index db1ecc74..dc97c607 100644 --- a/text_file_functions.cpp +++ b/text_file_functions.cpp @@ -1,6 +1,5 @@ #include "aoapplication.h" -#include "path_functions.h" #include "file_functions.h" #include <QTextStream> @@ -140,3 +139,38 @@ pos_size_type AOApplication::get_pos_and_size(QString p_identifier, QString p_de return return_value; } +QString AOApplication::get_char_side(QString p_char) +{ + QString char_ini_path = get_character_path(p_char) + "char.ini"; + + QFile char_ini; + + char_ini.setFileName(char_ini_path); + + if (!char_ini.open(QIODevice::ReadOnly)) + { + //default to wit and don't make a big deal about it + return "wit"; + } + + QTextStream in(&char_ini); + + while(!in.atEnd()) + { + QString line = in.readLine(); + + if (!line.startsWith("side")) + continue; + + QStringList line_elements = line.split("="); + + if (line_elements.size() < 2) + continue; + + //note that we do not validate if this is a valid side or not. that's up to the caller + return line_elements.at(1).trimmed().toLower(); + } + + return "wit"; +} + |
