API Fixes

* Fixed language codes being defined incorrectly.
* Fixed cleanliness codes being undefined.
* Disabled logging so that stdout doesn't get spammed.
* Fixed game initialisation, I was passing the game path as the BOSS
folder.
* Fixed crash when userlist isn't provided.
This commit is contained in:
WrinklyNinja
2014-01-12 11:37:11 +00:00
parent 8cf966fa20
commit 9b074f5caf
3 changed files with 33 additions and 17 deletions
+25 -13
View File
@@ -56,8 +56,8 @@ const unsigned int boss_error_invalid_args = boss::error::invalid_args;
const unsigned int boss_error_no_tag_map = boss::error::no_tag_map;
const unsigned int boss_error_path_not_found = boss::error::path_not_found;
const unsigned int boss_error_no_game_detected = boss::error::no_game_detected;
const unsigned int boss_error_windows_error = boss::error::windows_error;
const unsigned int boss_error_sorting_error = boss::error::windows_error;
const unsigned int boss_error_windows_error = boss::error::windows_error;
const unsigned int boss_error_sorting_error = boss::error::windows_error;
const unsigned int boss_return_max = boss_error_sorting_error;
// The following are the games identifiers used by the API.
@@ -70,12 +70,18 @@ const unsigned int boss_game_fonv = boss::g_game_fonv;
const unsigned int boss_message_say = boss::g_message_say;
const unsigned int boss_message_warn = boss::g_message_warn;
const unsigned int boss_message_error = boss::g_message_error;
const unsigned int boss_message_tag = boss::g_message_tag;
// BOSS message languages.
BOSS_API extern const unsigned int boss_lang_any = boss::g_lang_any;
BOSS_API extern const unsigned int boss_lang_english = boss::g_lang_english;
BOSS_API extern const unsigned int boss_lang_spanish = boss::g_lang_spanish;
BOSS_API extern const unsigned int boss_lang_russian = boss::g_lang_russian;
const unsigned int boss_lang_any = boss::g_lang_any;
const unsigned int boss_lang_english = boss::g_lang_english;
const unsigned int boss_lang_spanish = boss::g_lang_spanish;
const unsigned int boss_lang_russian = boss::g_lang_russian;
// BOSS cleanliness codes.
const unsigned int boss_needs_cleaning_no = 0;
const unsigned int boss_needs_cleaning_yes = 1;
const unsigned int boss_needs_cleaning_unknown = 2;
struct _boss_db_int {
@@ -214,13 +220,16 @@ BOSS_API unsigned int boss_create_db (boss_db * const db, const unsigned int cli
std::locale loc(global_loc, new boost::filesystem::detail::utf8_codecvt_facet());
boost::filesystem::path::imbue(loc);
//Disable logging or else stdout will get overrun.
boost::log::core::get()->set_logging_enabled(false);
std::string game_path = "";
if (gamePath != NULL)
game_path = gamePath;
boss::Game game;
try {
game = boss::Game(clientGame, game_path); //This also checks to see if the game is installed if game_path is empty and throws an exception if it is not detected.
game = boss::Game(clientGame).SetPath(game_path).Init(); //This also checks to see if the game is installed if game_path is empty and throws an exception if it is not detected. It also creates a folder in %LOCALAPPDATA% and reads the active plugins list, but that shouldn't be an issue.
} catch (boss::error& e) {
extMessageStr = e.what();
return e.code();
@@ -278,12 +287,15 @@ BOSS_API unsigned int boss_load_lists (boss_db db, const char * const masterlist
return boss_error_parse_fail;
}
try {
YAML::Node tempNode = YAML::LoadFile(userlistPath);
userTemp = tempNode["plugins"].as< std::list<boss::Plugin> >();
} catch (YAML::Exception& e) {
extMessageStr = e.what();
return boss_error_parse_fail;
if (userlistPath != NULL) {
try {
YAML::Node tempNode = YAML::LoadFile(userlistPath);
userTemp = tempNode["plugins"].as< std::list<boss::Plugin> >();
}
catch (YAML::Exception& e) {
extMessageStr = e.what();
return boss_error_parse_fail;
}
}
//Also free memory.
+6 -2
View File
@@ -60,8 +60,6 @@ namespace boss {
Game::Game() : id(g_game_autodetect) {}
Game::Game(const std::string& folder) : bossFolderName(folder) {}
Game::Game(const unsigned int gameCode, const std::string& folder) : id(gameCode) {
if (Id() == g_game_tes4) {
_name = "TES IV: Oblivion";
@@ -123,6 +121,12 @@ namespace boss {
return *this;
}
Game& Game::SetPath(const std::string& path) {
gamePath = path;
return *this;
}
Game& Game::Init() {
BOOST_LOG_TRIVIAL(trace) << "Initialising filesystem-related data for game: " << _name;
+2 -2
View File
@@ -44,11 +44,11 @@ namespace boss {
class Game {
public:
Game(); //Sets game to BOSS_g_game_autodetect, with all other vars being empty.
Game(const std::string& folder);
Game(const unsigned int baseGameCode, const std::string& folder = "");
Game(const unsigned int baseGameCode, const std::string& bossFolder = "");
Game& SetDetails(const std::string& name, const std::string& masterFile,
const std::string& url, const std::string& path, const std::string& registry);
Game& SetPath(const std::string& path); //Used by API.
Game& Init();
bool IsInstalled() const;