xoreos  0.0.5
probes.cpp
Go to the documentation of this file.
1 /* xoreos - A reimplementation of BioWare's Aurora engine
2  *
3  * xoreos is the legal property of its developers, whose names
4  * can be found in the AUTHORS file distributed with this source
5  * distribution.
6  *
7  * xoreos is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 3
10  * of the License, or (at your option) any later version.
11  *
12  * xoreos is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with xoreos. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
25 #include "src/common/ustring.h"
26 #include "src/common/filelist.h"
27 #include "src/common/filepath.h"
28 
30 
33 
34 namespace Engines {
35 
36 namespace KotOR2 {
37 
39 private:
40  static const Common::UString kGameName;
41 
42 public:
45 
47  return Aurora::kGameIDKotOR2;
48  }
49 
50  const Common::UString &getGameName() const {
51  return kGameName;
52  }
53 
54  bool probe(Common::SeekableReadStream &UNUSED(stream)) const {
55  return false;
56  }
57 
59  return new KotOR2Engine;
60  }
61 };
62 
63 const Common::UString EngineProbe::kGameName = "Star Wars: Knights of the Old Republic II - The Sith Lords";
64 
65 
67 public:
70 
72 
73  bool probe(const Common::UString &UNUSED(directory), const Common::FileList &rootFiles) const {
74 
75  // If "swkotor2.exe" exists, this should be a valid path for the Windows port
76  return rootFiles.contains("/swkotor2.exe", true);
77  }
78 
79 };
80 
81 class EngineProbeLinux : public EngineProbe {
82 public:
85 
87 
88  bool probe(const Common::UString &directory, const Common::FileList &rootFiles) const {
89 
90  // The game binary found in the Aspyr Linux port
91  if (!rootFiles.contains("/KOTOR2", false))
92  return false;
93 
94  // The directory containing what was originally within the PE resources
95  if (Common::FilePath::findSubDirectory(directory, "resources").empty())
96  return false;
97  // The directory containing the original game data files
98  if (Common::FilePath::findSubDirectory(directory, "steamassets").empty())
99  return false;
100 
101  return true;
102  }
103 
104 };
105 
106 class EngineProbeMac : public EngineProbe {
107 public:
110 
112 
113  bool probe(const Common::UString &directory, const Common::FileList &UNUSED(rootFiles)) const {
114 
115  // The directory containing the Mac binary
116  if (Common::FilePath::findSubDirectory(directory, "MacOS").empty())
117  return false;
118  // The directory containing what was originally within the PE resources
119  if (Common::FilePath::findSubDirectory(directory, "Resources").empty())
120  return false;
121  // The directory containing the original game data files
122  if (Common::FilePath::findSubDirectory(directory, "GameData").empty())
123  return false;
124 
125  // The game binary found in the Aspyr Mac port
126  Common::FileList binaryFiles(Common::FilePath::findSubDirectory(directory, "MacOS"));
127  if (!binaryFiles.contains("KOTOR2", false))
128  return false;
129 
130  return true;
131  }
132 
133 };
134 
135 class EngineProbeXbox : public EngineProbe {
136 public:
139 
141 
142  bool probe(const Common::UString &directory, const Common::FileList &rootFiles) const {
143 
144  // If the "dataxbox" directory exists and "weapons.erf" exists,
145  // this should be a valid path for the Xbox port
146  const Common::UString appDirectory = Common::FilePath::findSubDirectory(directory, "dataxbox");
147 
148  return !appDirectory.empty() && rootFiles.contains("/weapons.erf", true);
149  }
150 
151 };
152 
153 
154 void createEngineProbes(std::list<const ::Engines::EngineProbe *> &probes) {
155  probes.push_back(new EngineProbeWindows);
156  probes.push_back(new EngineProbeLinux);
157  probes.push_back(new EngineProbeMac);
158  probes.push_back(new EngineProbeXbox);
159 }
160 
161 } // End of namespace KotOR2
162 
163 } // End of namespace Engines
GameID
Definition: types.h:393
A class holding an UTF-8 string.
Definition: ustring.h:48
void createEngineProbes(std::list< const ::Engines::EngineProbe *> &probes)
Definition: probes.cpp:154
A probe that checks if an engine can handle game data found in a specific directory and creates an in...
bool probe(const Common::UString &directory, const Common::FileList &rootFiles) const
Check for the game in that directory, containing these files.
Definition: probes.cpp:142
Aurora::Platform getPlatform() const
Get the Platform that the probe is able to detect.
Definition: probes.cpp:140
const Common::UString & getGameName() const
Return a string of the full game name.
Definition: probes.cpp:50
bool probe(const Common::UString &directory, const Common::FileList &rootFiles) const
Check for the game in that directory, containing these files.
Definition: probes.cpp:73
#define UNUSED(x)
Definition: system.h:170
Probing for an installation of Star Wars: Knights of the Old Republic II - The Sith Lords...
Microsoft Xbox.
Definition: types.h:433
bool empty() const
Is the string empty?
Definition: ustring.cpp:245
Unicode string handling.
GNU/Linux.
Definition: types.h:432
The base class for an engine within BioWare&#39;s Aurora family.
Definition: engine.h:49
A probe able to detect one specific game.
Definition: engineprobe.h:44
Aurora::Platform getPlatform() const
Get the Platform that the probe is able to detect.
Definition: probes.cpp:111
Engines::Engine * createEngine() const
Create the respective engine for the GameID.
Definition: probes.cpp:58
static const Common::UString kGameName
Definition: probes.cpp:40
A list of files.
Definition: filelist.h:35
Aurora::GameID getGameID() const
Get the GameID that the probe is able to detect.
Definition: probes.cpp:46
Microsoft Windows.
Definition: types.h:430
A list of files.
bool probe(Common::SeekableReadStream &stream) const
Check for the game in that file.
Definition: probes.cpp:54
Aurora::Platform getPlatform() const
Get the Platform that the probe is able to detect.
Definition: probes.cpp:86
Star Wars: Knights of the Old Republic II - The Sith Lords.
Definition: types.h:398
Interface for a seekable & readable data stream.
Definition: readstream.h:265
Engine class handling Star Wars: Knights of the Old Republic II - The Sith Lords. ...
Platform
Definition: types.h:429
bool probe(const Common::UString &directory, const Common::FileList &rootFiles) const
Check for the game in that directory, containing these files.
Definition: probes.cpp:88
Utility class for manipulating file paths.
bool probe(const Common::UString &directory, const Common::FileList &rootFiles) const
Check for the game in that directory, containing these files.
Definition: probes.cpp:113
static UString findSubDirectory(const UString &directory, const UString &subDirectory, bool caseInsensitive=false)
Find a directory&#39;s subdirectory.
Definition: filepath.cpp:318
bool contains(const UString &str, bool caseInsensitive) const
Does the list contain at least one file ending with the given string?
Definition: filelist.cpp:185
Aurora::Platform getPlatform() const
Get the Platform that the probe is able to detect.
Definition: probes.cpp:71