1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-03-29 19:06:41 +00:00

some cleanup

This commit is contained in:
Marc Zinnschlag 2013-03-15 10:26:04 +01:00
parent 727a598cbe
commit 66a2df68db
4 changed files with 17 additions and 6 deletions

View file

@ -2,6 +2,9 @@
#include "boost/lexical_cast.hpp" #include "boost/lexical_cast.hpp"
namespace MWWorld namespace MWWorld
{ {
Fallback::Fallback(const std::map<std::string,std::string>& fallback):mFallbackMap(fallback)
{}
std::string Fallback::getFallbackString(const std::string& fall) const std::string Fallback::getFallbackString(const std::string& fall) const
{ {
std::map<std::string,std::string>::const_iterator it; std::map<std::string,std::string>::const_iterator it;
@ -14,7 +17,7 @@ namespace MWWorld
float Fallback::getFallbackFloat(const std::string& fall) const float Fallback::getFallbackFloat(const std::string& fall) const
{ {
std::string fallback=getFallbackString(fall); std::string fallback=getFallbackString(fall);
if(fallback=="") if(fallback.empty())
return 0; return 0;
else else
return boost::lexical_cast<float>(fallback); return boost::lexical_cast<float>(fallback);
@ -22,7 +25,7 @@ namespace MWWorld
bool Fallback::getFallbackBool(const std::string& fall) const bool Fallback::getFallbackBool(const std::string& fall) const
{ {
std::string fallback=getFallbackString(fall); std::string fallback=getFallbackString(fall);
if(fallback=="") if(fallback.empty())
return false; return false;
else else
return boost::lexical_cast<bool>(fallback); return boost::lexical_cast<bool>(fallback);
@ -30,13 +33,13 @@ namespace MWWorld
Ogre::ColourValue Fallback::getFallbackColour(const std::string& fall) const Ogre::ColourValue Fallback::getFallbackColour(const std::string& fall) const
{ {
std::string sum=getFallbackString(fall); std::string sum=getFallbackString(fall);
if(sum=="") if(sum.empty())
return Ogre::ColourValue(0,0,0); return Ogre::ColourValue(0,0,0);
else else
{ {
std::string ret[3]; std::string ret[3];
unsigned int j=0; unsigned int j=0;
for(unsigned int i=0;i<sum.length();i++){ for(unsigned int i=0;i<sum.length();++i){
if(sum[i]==',') j++; if(sum[i]==',') j++;
else ret[j]+=sum[i]; else ret[j]+=sum[i];
} }

View file

@ -1,13 +1,18 @@
#ifndef GAME_MWWORLD_FALLBACK_H #ifndef GAME_MWWORLD_FALLBACK_H
#define GAME_MWWORLD_FALLBACK_H #define GAME_MWWORLD_FALLBACK_H
#include <map>
#include <string>
#include <OgreColourValue.h> #include <OgreColourValue.h>
namespace MWWorld namespace MWWorld
{ {
class Fallback class Fallback
{ {
const std::map<std::string,std::string> mFallbackMap; const std::map<std::string,std::string> mFallbackMap;
public: public:
Fallback(const std::map<std::string,std::string> fallback):mFallbackMap(fallback){}; Fallback(const std::map<std::string,std::string>& fallback);
std::string getFallbackString(const std::string& fall) const; std::string getFallbackString(const std::string& fall) const;
float getFallbackFloat(const std::string& fall) const; float getFallbackFloat(const std::string& fall) const;
bool getFallbackBool(const std::string& fall) const; bool getFallbackBool(const std::string& fall) const;

View file

@ -12,6 +12,7 @@
#include "player.hpp" #include "player.hpp"
#include "esmstore.hpp" #include "esmstore.hpp"
#include "fallback.hpp"
using namespace Ogre; using namespace Ogre;
using namespace MWWorld; using namespace MWWorld;

View file

@ -3,7 +3,7 @@
#include <OgreString.h> #include <OgreString.h>
#include <OgreColourValue.h> #include <OgreColourValue.h>
#include "fallback.hpp"
namespace MWRender namespace MWRender
{ {
class RenderingManager; class RenderingManager;
@ -11,6 +11,8 @@ namespace MWRender
namespace MWWorld namespace MWWorld
{ {
class Fallback;
/// Defines the actual weather that results from weather setting (see below), time of day and weather transition /// Defines the actual weather that results from weather setting (see below), time of day and weather transition
struct WeatherResult struct WeatherResult
{ {