Skip to content

Commit

Permalink
NWN: Move probes into their own file, probes.h/.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
DrMcCoy committed Aug 2, 2015
1 parent 3d05549 commit c802325
Show file tree
Hide file tree
Showing 6 changed files with 191 additions and 118 deletions.
2 changes: 1 addition & 1 deletion src/engines/enginemanager.cpp
Expand Up @@ -56,7 +56,7 @@
#include "src/engines/aurora/model.h"

// The engines
#include "src/engines/nwn/nwn.h"
#include "src/engines/nwn/probes.h"
#include "src/engines/nwn2/nwn2.h"
#include "src/engines/kotor/kotor.h"
#include "src/engines/kotor2/kotor2.h"
Expand Down
2 changes: 2 additions & 0 deletions src/engines/nwn/Makefile.am
Expand Up @@ -4,6 +4,7 @@ noinst_LTLIBRARIES = libnwn.la

noinst_HEADERS = \
nwn.h \
probes.h \
types.h \
modelloader.h \
version.h \
Expand Down Expand Up @@ -87,6 +88,7 @@ noinst_HEADERS = \

libnwn_la_SOURCES = \
nwn.cpp \
probes.cpp \
types.cpp \
modelloader.cpp \
version.cpp \
Expand Down
48 changes: 0 additions & 48 deletions src/engines/nwn/nwn.cpp
Expand Up @@ -66,54 +66,6 @@ namespace Engines {

namespace NWN {

const NWNEngineProbeWindows kNWNEngineProbeWin;
const NWNEngineProbeMac kNWNEngineProbeMac;
const NWNEngineProbeLinux kNWNEngineProbeLinux;
const NWNEngineProbeFallback kNWNEngineProbeFallback;

const Common::UString NWNEngineProbe::kGameName = "Neverwinter Nights";

Engines::Engine *NWNEngineProbe::createEngine() const {
return new NWNEngine;
}

bool NWNEngineProbeWindows::probe(const Common::UString &UNUSED(directory),
const Common::FileList &rootFiles) const {

// Look for the Windows binary nwmain.exe
return rootFiles.contains("/nwmain.exe", true);
}

bool NWNEngineProbeMac::probe(const Common::UString &directory,
const Common::FileList &UNUSED(rootFiles)) const {

// Look for the app directory containing the Mac OS X binary
return !Common::FilePath::findSubDirectory(directory, "Neverwinter Nights.app", true).empty();
}

bool NWNEngineProbeLinux::probe(const Common::UString &UNUSED(directory),
const Common::FileList &rootFiles) const {

// Look for the Linux binary nwmain
return rootFiles.contains("/nwmain", true);
}

bool NWNEngineProbeFallback::probe(const Common::UString &UNUSED(directory),
const Common::FileList &rootFiles) const {

// Don't accidentally trigger on NWN2
if (rootFiles.contains("/nwn2.ini", true))
return false;
if (rootFiles.contains("/nwn2main.exe", true))
return false;

// As a fallback, look for the nwn.ini, nwnplayer.ini or nwncdkey.ini
return rootFiles.contains("/nwn.ini", true) ||
rootFiles.contains("/nwnplayer.ini", true) ||
rootFiles.contains("/nwncdkey.ini", true);
}


NWNEngine::NWNEngine() : _version(0), _language(Aurora::kLanguageInvalid),
_hasXP1(false), _hasXP2(false), _hasXP3(false), _scriptFuncs(0), _module(0) {

Expand Down
69 changes: 0 additions & 69 deletions src/engines/nwn/nwn.h
Expand Up @@ -34,11 +34,6 @@
#include "src/sound/types.h"

#include "src/engines/engine.h"
#include "src/engines/engineprobe.h"

namespace Common {
class FileList;
}

namespace Engines {

Expand All @@ -52,70 +47,6 @@ class ScriptFunctions;
class GUI;
class Module;

class NWNEngineProbe : public Engines::EngineProbe {
private:
static const Common::UString kGameName;

public:
NWNEngineProbe() {}
~NWNEngineProbe() {}

Aurora::GameID getGameID() const {
return Aurora::kGameIDNWN;
}

const Common::UString &getGameName() const {
return kGameName;
}

bool probe(Common::SeekableReadStream &UNUSED(stream)) const {
return false;
}

Engines::Engine *createEngine() const;
};

class NWNEngineProbeWindows : public NWNEngineProbe {
public:
NWNEngineProbeWindows() {}
~NWNEngineProbeWindows() {}

bool probe(const Common::UString &directory, const Common::FileList &rootFiles) const;
Aurora::Platform getPlatform() const { return Aurora::kPlatformWindows; }
};

class NWNEngineProbeMac : public NWNEngineProbe {
public:
NWNEngineProbeMac() {}
~NWNEngineProbeMac() {}

bool probe(const Common::UString &directory, const Common::FileList &rootFiles) const;
Aurora::Platform getPlatform() const { return Aurora::kPlatformMacOSX; }
};

class NWNEngineProbeLinux: public NWNEngineProbe {
public:
NWNEngineProbeLinux() {}
~NWNEngineProbeLinux() {}

bool probe(const Common::UString &directory, const Common::FileList &rootFiles) const;
Aurora::Platform getPlatform() const { return Aurora::kPlatformLinux; }
};

class NWNEngineProbeFallback : public NWNEngineProbe {
public:
NWNEngineProbeFallback() {}
~NWNEngineProbeFallback() {}

bool probe(const Common::UString &directory, const Common::FileList &rootFiles) const;
Aurora::Platform getPlatform() const { return Aurora::kPlatformUnknown; }
};

extern const NWNEngineProbeWindows kNWNEngineProbeWin;
extern const NWNEngineProbeMac kNWNEngineProbeMac;
extern const NWNEngineProbeLinux kNWNEngineProbeLinux;
extern const NWNEngineProbeFallback kNWNEngineProbeFallback;

class NWNEngine : public Engines::Engine {
public:
NWNEngine();
Expand Down
84 changes: 84 additions & 0 deletions src/engines/nwn/probes.cpp
@@ -0,0 +1,84 @@
/* xoreos - A reimplementation of BioWare's Aurora engine
*
* xoreos is the legal property of its developers, whose names
* can be found in the AUTHORS file distributed with this source
* distribution.
*
* xoreos is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* xoreos is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with xoreos. If not, see <http://www.gnu.org/licenses/>.
*/

/** @file
* Probing for an installation of Neverwinter Nights.
*/

#include "src/common/filelist.h"
#include "src/common/filepath.h"

#include "src/engines/nwn/probes.h"
#include "src/engines/nwn/nwn.h"

namespace Engines {

namespace NWN {

const NWNEngineProbeWindows kNWNEngineProbeWin;
const NWNEngineProbeMac kNWNEngineProbeMac;
const NWNEngineProbeLinux kNWNEngineProbeLinux;
const NWNEngineProbeFallback kNWNEngineProbeFallback;

const Common::UString NWNEngineProbe::kGameName = "Neverwinter Nights";

Engines::Engine *NWNEngineProbe::createEngine() const {
return new NWNEngine;
}

bool NWNEngineProbeWindows::probe(const Common::UString &UNUSED(directory),
const Common::FileList &rootFiles) const {

// Look for the Windows binary nwmain.exe
return rootFiles.contains("/nwmain.exe", true);
}

bool NWNEngineProbeMac::probe(const Common::UString &directory,
const Common::FileList &UNUSED(rootFiles)) const {

// Look for the app directory containing the Mac OS X binary
return !Common::FilePath::findSubDirectory(directory, "Neverwinter Nights.app", true).empty();
}

bool NWNEngineProbeLinux::probe(const Common::UString &UNUSED(directory),
const Common::FileList &rootFiles) const {

// Look for the Linux binary nwmain
return rootFiles.contains("/nwmain", true);
}

bool NWNEngineProbeFallback::probe(const Common::UString &UNUSED(directory),
const Common::FileList &rootFiles) const {

// Don't accidentally trigger on NWN2
if (rootFiles.contains("/nwn2.ini", true))
return false;
if (rootFiles.contains("/nwn2main.exe", true))
return false;

// As a fallback, look for the nwn.ini, nwnplayer.ini or nwncdkey.ini
return rootFiles.contains("/nwn.ini", true) ||
rootFiles.contains("/nwnplayer.ini", true) ||
rootFiles.contains("/nwncdkey.ini", true);
}

} // End of namespace NWN

} // End of namespace Engines
104 changes: 104 additions & 0 deletions src/engines/nwn/probes.h
@@ -0,0 +1,104 @@
/* xoreos - A reimplementation of BioWare's Aurora engine
*
* xoreos is the legal property of its developers, whose names
* can be found in the AUTHORS file distributed with this source
* distribution.
*
* xoreos is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version.
*
* xoreos is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with xoreos. If not, see <http://www.gnu.org/licenses/>.
*/

/** @file
* Probing for an installation of Neverwinter Nights.
*/

#ifndef ENGINES_NWN_PROBES_H
#define ENGINES_NWN_PROBES_H

#include "src/common/ustring.h"

#include "src/engines/engineprobe.h"

namespace Engines {

namespace NWN {

class NWNEngineProbe : public Engines::EngineProbe {
private:
static const Common::UString kGameName;

public:
NWNEngineProbe() {}
~NWNEngineProbe() {}

Aurora::GameID getGameID() const {
return Aurora::kGameIDNWN;
}

const Common::UString &getGameName() const {
return kGameName;
}

bool probe(Common::SeekableReadStream &UNUSED(stream)) const {
return false;
}

Engines::Engine *createEngine() const;
};

class NWNEngineProbeWindows : public NWNEngineProbe {
public:
NWNEngineProbeWindows() {}
~NWNEngineProbeWindows() {}

bool probe(const Common::UString &directory, const Common::FileList &rootFiles) const;
Aurora::Platform getPlatform() const { return Aurora::kPlatformWindows; }
};

class NWNEngineProbeMac : public NWNEngineProbe {
public:
NWNEngineProbeMac() {}
~NWNEngineProbeMac() {}

bool probe(const Common::UString &directory, const Common::FileList &rootFiles) const;
Aurora::Platform getPlatform() const { return Aurora::kPlatformMacOSX; }
};

class NWNEngineProbeLinux: public NWNEngineProbe {
public:
NWNEngineProbeLinux() {}
~NWNEngineProbeLinux() {}

bool probe(const Common::UString &directory, const Common::FileList &rootFiles) const;
Aurora::Platform getPlatform() const { return Aurora::kPlatformLinux; }
};

class NWNEngineProbeFallback : public NWNEngineProbe {
public:
NWNEngineProbeFallback() {}
~NWNEngineProbeFallback() {}

bool probe(const Common::UString &directory, const Common::FileList &rootFiles) const;
Aurora::Platform getPlatform() const { return Aurora::kPlatformUnknown; }
};

extern const NWNEngineProbeWindows kNWNEngineProbeWin;
extern const NWNEngineProbeMac kNWNEngineProbeMac;
extern const NWNEngineProbeLinux kNWNEngineProbeLinux;
extern const NWNEngineProbeFallback kNWNEngineProbeFallback;

} // End of namespace NWN

} // End of namespace Engines

#endif // ENGINES_NWN_PROBES_H

0 comments on commit c802325

Please sign in to comment.