[Orxonox-commit 929] r5652 - in code/branches/resource2/src: core orxonox/gamestates orxonox/tools
rgrieder at orxonox.net
rgrieder at orxonox.net
Mon Aug 17 15:35:34 CEST 2009
Author: rgrieder
Date: 2009-08-17 15:35:34 +0200 (Mon, 17 Aug 2009)
New Revision: 5652
Modified:
code/branches/resource2/src/core/Clock.h
code/branches/resource2/src/core/ConfigFileManager.cc
code/branches/resource2/src/core/ConfigFileManager.h
code/branches/resource2/src/orxonox/gamestates/GSDedicated.cc
code/branches/resource2/src/orxonox/tools/ResourceCollection.cc
code/branches/resource2/src/orxonox/tools/ResourceLocation.cc
Log:
Modified ResourceLocation to actually find the given paths.
Plus a few small changes.
Modified: code/branches/resource2/src/core/Clock.h
===================================================================
--- code/branches/resource2/src/core/Clock.h 2009-08-17 13:17:15 UTC (rev 5651)
+++ code/branches/resource2/src/core/Clock.h 2009-08-17 13:35:34 UTC (rev 5652)
@@ -20,9 +20,9 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Author:
- * Fabian 'x3n' Landau
+ * Reto Grieder
* Co-authors:
- * Reto Grieder
+ * ...
*
*/
Modified: code/branches/resource2/src/core/ConfigFileManager.cc
===================================================================
--- code/branches/resource2/src/core/ConfigFileManager.cc 2009-08-17 13:17:15 UTC (rev 5651)
+++ code/branches/resource2/src/core/ConfigFileManager.cc 2009-08-17 13:35:34 UTC (rev 5652)
@@ -39,10 +39,6 @@
namespace orxonox
{
- const char* const DEFAULT_CONFIG_FILE = "default.ini";
-
- ConfigFileManager* ConfigFileManager::singletonPtr_s = 0;
-
SetConsoleCommandShortcutExtern(config).argumentCompleter(0, autocompletion::configvalueclasses()).argumentCompleter(1, autocompletion::configvalues()).argumentCompleter(2, autocompletion::configvalue());
SetConsoleCommandShortcutExtern(tconfig).argumentCompleter(0, autocompletion::configvalueclasses()).argumentCompleter(1, autocompletion::configvalues()).argumentCompleter(2, autocompletion::configvalue());
SetConsoleCommandShortcutExtern(reloadConfig);
@@ -338,10 +334,8 @@
void ConfigFile::save() const
{
- boost::filesystem::path filepath(Core::getConfigPath() / this->filename_);
-
std::ofstream file;
- file.open(filepath.string().c_str(), std::fstream::out);
+ file.open((Core::getConfigPathString() + filename_).c_str(), std::fstream::out);
file.setf(std::ios::fixed, std::ios::floatfield);
file.precision(6);
@@ -478,6 +472,10 @@
// ConfigFileManager //
///////////////////////
+ ConfigFileManager* ConfigFileManager::singletonPtr_s = 0;
+
+ std::string ConfigFileManager::DEFAULT_CONFIG_FILE = "default.ini";
+
ConfigFileManager::ConfigFileManager()
: mininmalFreeType_(ConfigFileType::numberOfReservedTypes)
{
Modified: code/branches/resource2/src/core/ConfigFileManager.h
===================================================================
--- code/branches/resource2/src/core/ConfigFileManager.h 2009-08-17 13:17:15 UTC (rev 5651)
+++ code/branches/resource2/src/core/ConfigFileManager.h 2009-08-17 13:35:34 UTC (rev 5652)
@@ -306,6 +306,8 @@
void updateConfigValues();
void updateConfigValues(ConfigFileType type);
+ static std::string DEFAULT_CONFIG_FILE;
+
private:
ConfigFileManager(const ConfigFileManager&);
Modified: code/branches/resource2/src/orxonox/gamestates/GSDedicated.cc
===================================================================
--- code/branches/resource2/src/orxonox/gamestates/GSDedicated.cc 2009-08-17 13:17:15 UTC (rev 5651)
+++ code/branches/resource2/src/orxonox/gamestates/GSDedicated.cc 2009-08-17 13:35:34 UTC (rev 5652)
@@ -28,6 +28,10 @@
#include "GSDedicated.h"
+#include <iomanip>
+#include <iostream>
+#include <boost/bind.hpp>
+
#include "util/Debug.h"
#include "util/Sleep.h"
#include "core/Clock.h"
@@ -37,10 +41,6 @@
#include "core/GameMode.h"
#include "network/Server.h"
-#include <iostream>
-#include <iomanip>
-#include <boost/bind.hpp>
-
#ifdef ORXONOX_PLATFORM_UNIX
#include <termios.h>
#endif
Modified: code/branches/resource2/src/orxonox/tools/ResourceCollection.cc
===================================================================
--- code/branches/resource2/src/orxonox/tools/ResourceCollection.cc 2009-08-17 13:17:15 UTC (rev 5651)
+++ code/branches/resource2/src/orxonox/tools/ResourceCollection.cc 2009-08-17 13:35:34 UTC (rev 5652)
@@ -35,6 +35,8 @@
namespace orxonox
{
+ CreateFactory(ResourceCollection);
+
ResourceCollection::ResourceCollection(BaseObject* creator)
: BaseObject(creator)
{
Modified: code/branches/resource2/src/orxonox/tools/ResourceLocation.cc
===================================================================
--- code/branches/resource2/src/orxonox/tools/ResourceLocation.cc 2009-08-17 13:17:15 UTC (rev 5651)
+++ code/branches/resource2/src/orxonox/tools/ResourceLocation.cc 2009-08-17 13:35:34 UTC (rev 5652)
@@ -29,12 +29,18 @@
#include "ResourceLocation.h"
#include <OgreResourceGroupManager.h>
+#include <boost/filesystem.hpp>
+
#include "util/Exception.h"
+#include "core/Core.h"
#include "core/CoreIncludes.h"
+#include "core/XMLFile.h"
#include "core/XMLPort.h"
namespace orxonox
{
+ CreateFactory(ResourceLocation);
+
ResourceLocation::ResourceLocation(BaseObject* creator)
: BaseObject(creator)
{
@@ -42,7 +48,7 @@
// Default values
archiveType_ = "FileSystem";
- bRecursive_ = false;
+ bRecursive_ = true;
}
ResourceLocation::~ResourceLocation()
@@ -62,9 +68,22 @@
{
if (path_.empty())
ThrowException(InitialisationFailed, "ResourceLocation: Trying to add one without the path being set");
+
+ // Find the path
+ boost::filesystem::path path;
+ if (boost::filesystem::exists(Core::getDataPath() / this->getPath()))
+ path = Core::getDataPath() / this->getPath();
+ else if (Core::isDevelopmentRun() && boost::filesystem::exists(Core::getExternalDataPath() / this->getPath()))
+ path = Core::getExternalDataPath() / this->getPath();
+ else
+ {
+ COUT(2) << "Warning: ResourceLocation '" << this->getPath() << "' does not seem to exist" << std::endl;
+ return;
+ }
+
// Add it to the Ogre paths
Ogre::ResourceGroupManager::getSingleton().addResourceLocation(
- this->getPath(), this->getArchiveType(), resourceGroup, this->getRecursive());
+ path.string(), this->getArchiveType(), resourceGroup, this->getRecursive());
resourceGroup_ = resourceGroup;
}
More information about the Orxonox-commit
mailing list