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 
31 #include "src/engines/nwn/probes.h"
32 #include "src/engines/nwn/nwn.h"
33 
34 namespace Engines {
35 
36 namespace NWN {
37 
39 private:
40  static const Common::UString kGameName;
41 
42 public:
45 
47  return Aurora::kGameIDNWN;
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 NWNEngine;
60  }
61 };
62 
63 const Common::UString EngineProbe::kGameName = "Neverwinter Nights";
64 
65 
67 public:
70 
72 
73  bool probe(const Common::UString &UNUSED(directory), const Common::FileList &rootFiles) const {
74 
75  // Look for the Windows binary nwmain.exe
76  return rootFiles.contains("/nwmain.exe", true);
77  }
78 
79 };
80 
81 class EngineProbeMac : public EngineProbe {
82 public:
85 
87 
88  bool probe(const Common::UString &directory, const Common::FileList &UNUSED(rootFiles)) const {
89 
90  // Look for the app directory containing the Mac OS X binary
91  return !Common::FilePath::findSubDirectory(directory, "Neverwinter Nights.app", true).empty();
92  }
93 
94 };
95 
97 public:
100 
102 
103  bool probe(const Common::UString &UNUSED(directory), const Common::FileList &rootFiles) const {
104 
105  // Look for the Linux binary nwmain
106  return rootFiles.contains("/nwmain", true);
107  }
108 
109 };
110 
112 public:
115 
117 
118  bool probe(const Common::UString &UNUSED(directory), const Common::FileList &rootFiles) const {
119 
120  // Don't accidentally trigger on NWN2
121  if (rootFiles.contains("/nwn2.ini", true))
122  return false;
123  if (rootFiles.contains("/nwn2main.exe", true))
124  return false;
125 
126  // As a fallback, look for the nwn.ini, nwnplayer.ini or nwncdkey.ini
127  return rootFiles.contains("/nwn.ini", true) ||
128  rootFiles.contains("/nwnplayer.ini", true) ||
129  rootFiles.contains("/nwncdkey.ini", true);
130  }
131 
132 };
133 
134 
135 void createEngineProbes(std::list<const ::Engines::EngineProbe *> &probes) {
136  probes.push_back(new EngineProbeWindows);
137  probes.push_back(new EngineProbeMac);
138  probes.push_back(new EngineProbeLinux);
139  probes.push_back(new EngineProbeFallback);
140 }
141 
142 } // End of namespace NWN
143 
144 } // End of namespace Engines
GameID
Definition: types.h:393
Probing for an installation of Neverwinter Nights.
Engine class handling Neverwinter Nights.
A class holding an UTF-8 string.
Definition: ustring.h:48
Aurora::Platform getPlatform() const
Get the Platform that the probe is able to detect.
Definition: probes.cpp:101
bool probe(const Common::UString &directory, const Common::FileList &rootFiles) const
Check for the game in that directory, containing these files.
Definition: probes.cpp:118
bool probe(const Common::UString &directory, const Common::FileList &rootFiles) const
Check for the game in that directory, containing these files.
Definition: probes.cpp:103
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:73
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
Engines::Engine * createEngine() const
Create the respective engine for the GameID.
Definition: probes.cpp:58
const Common::UString & getGameName() const
Return a string of the full game name.
Definition: probes.cpp:50
#define UNUSED(x)
Definition: system.h:170
bool empty() const
Is the string empty?
Definition: ustring.cpp:245
void createEngineProbes(std::list< const ::Engines::EngineProbe *> &probes)
Definition: probes.cpp:135
Aurora::GameID getGameID() const
Get the GameID that the probe is able to detect.
Definition: probes.cpp:46
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:86
A list of files.
Definition: filelist.h:35
Microsoft Windows.
Definition: types.h:430
Aurora::Platform getPlatform() const
Get the Platform that the probe is able to detect.
Definition: probes.cpp:116
A list of files.
Neverwinter Nights.
Definition: types.h:395
bool probe(Common::SeekableReadStream &stream) const
Check for the game in that file.
Definition: probes.cpp:54
Unknown (must be last).
Definition: types.h:439
Interface for a seekable & readable data stream.
Definition: readstream.h:265
Platform
Definition: types.h:429
Utility class for manipulating file paths.
static const Common::UString kGameName
Definition: probes.cpp:40
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