@@ -34,6 +34,29 @@ using boost::format;
34
34
using std::string;
35
35
36
36
namespace loot {
37
+ unsigned int mapGameId (GameType gameType) {
38
+ switch (gameType) {
39
+ case GameType::tes4:
40
+ return LIBLO_GAME_TES4;
41
+ case GameType::tes5:
42
+ return LIBLO_GAME_TES5;
43
+ case GameType::tes5se:
44
+ return LIBLO_GAME_TES5SE;
45
+ case GameType::tes5vr:
46
+ return LIBLO_GAME_TES5VR;
47
+ case GameType::fo3:
48
+ return LIBLO_GAME_FO3;
49
+ case GameType::fonv:
50
+ return LIBLO_GAME_FNV;
51
+ case GameType::fo4:
52
+ return LIBLO_GAME_FO4;
53
+ case GameType::fo4vr:
54
+ return LIBLO_GAME_FO4VR;
55
+ default :
56
+ return (unsigned int )-1 ;
57
+ }
58
+ }
59
+
37
60
LoadOrderHandler::LoadOrderHandler () : gh_(nullptr ) {}
38
61
39
62
LoadOrderHandler::~LoadOrderHandler () { lo_destroy_handle (gh_); }
@@ -56,30 +79,8 @@ void LoadOrderHandler::Init(const GameType& gameType,
56
79
gh_ = nullptr ;
57
80
}
58
81
59
- int ret;
60
- if (gameType == GameType::tes4)
61
- ret = lo_create_handle (
62
- &gh_, LIBLO_GAME_TES4, gamePath.string ().c_str (), gameLocalDataPath);
63
- else if (gameType == GameType::tes5)
64
- ret = lo_create_handle (
65
- &gh_, LIBLO_GAME_TES5, gamePath.string ().c_str (), gameLocalDataPath);
66
- else if (gameType == GameType::tes5se)
67
- ret = lo_create_handle (
68
- &gh_, LIBLO_GAME_TES5SE, gamePath.string ().c_str (), gameLocalDataPath);
69
- else if (gameType == GameType::fo3)
70
- ret = lo_create_handle (
71
- &gh_, LIBLO_GAME_FO3, gamePath.string ().c_str (), gameLocalDataPath);
72
- else if (gameType == GameType::fonv)
73
- ret = lo_create_handle (
74
- &gh_, LIBLO_GAME_FNV, gamePath.string ().c_str (), gameLocalDataPath);
75
- else if (gameType == GameType::fo4)
76
- ret = lo_create_handle (
77
- &gh_, LIBLO_GAME_FO4, gamePath.string ().c_str (), gameLocalDataPath);
78
- else if (gameType == GameType::fo4vr)
79
- ret = lo_create_handle (
80
- &gh_, LIBLO_GAME_FO4VR, gamePath.string ().c_str (), gameLocalDataPath);
81
- else
82
- ret = LIBLO_ERROR_INVALID_ARGS;
82
+ int ret = lo_create_handle (
83
+ &gh_, mapGameId (gameType), gamePath.string ().c_str (), gameLocalDataPath);
83
84
84
85
HandleError (" create a game handle" , ret);
85
86
}
0 commit comments