Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2848


Ignore:
Timestamp:
Mar 25, 2009, 7:37:00 PM (16 years ago)
Author:
rgrieder
Message:

Exported showsGraphics, etc. to a new class named GameMode in the core.

Location:
code/branches/gui/src
Files:
43 edited
2 copied

Legend:

Unmodified
Added
Removed
  • code/branches/gui/src/core/CMakeLists.txt

    r2844 r2848  
    2525  Event.cc
    2626  Game.cc
     27  GameMode.cc
    2728  GameState.cc
    2829  Language.cc
  • code/branches/gui/src/core/Core.cc

    r2846 r2848  
    8181    static boost::filesystem::path logPath_g;                   //!< Path to the log file folder
    8282
    83     bool Core::bShowsGraphics_s = false;
    84     bool Core::bHasServer_s     = false;
    85     bool Core::bIsClient_s      = false;
    86     bool Core::bIsStandalone_s  = false;
    87     bool Core::bIsMaster_s      = false;
    88 
    8983    Core* Core::singletonRef_s  = 0;
    9084
  • code/branches/gui/src/core/Core.h

    r2846 r2848  
    8383            static std::string getLogPathString();
    8484
    85             // fast access global variables.
    86             static bool showsGraphics() { return bShowsGraphics_s; }
    87             static bool hasServer()     { return bHasServer_s; }
    88             static bool isClient()      { return bIsClient_s; }
    89             static bool isStandalone()  { return bIsStandalone_s; }
    90             static bool isMaster()      { return bIsMaster_s; }
    91             static void setShowsGraphics(bool val) { bShowsGraphics_s = val; updateIsMaster(); }
    92             static void setHasServer    (bool val) { bHasServer_s     = val; updateIsMaster(); }
    93             static void setIsClient     (bool val) { bIsClient_s      = val; updateIsMaster(); }
    94             static void setIsStandalone (bool val) { bIsStandalone_s  = val; updateIsMaster(); }
    95             static void updateIsMaster  ()         { bIsMaster_s      = (bHasServer_s || bIsStandalone_s); }
    96 
    9785        private:
    9886            Core(const Core&);
     
    129117            bool loaded_;                                   //!< Only true if constructor was interrupted
    130118
    131             static bool bShowsGraphics_s;                   //!< global variable that tells whether to show graphics
    132             static bool bHasServer_s;                       //!< global variable that tells whether this is a server
    133             static bool bIsClient_s;
    134             static bool bIsStandalone_s;
    135             static bool bIsMaster_s;
    136 
    137119            static Core* singletonRef_s;
    138120    };
  • code/branches/gui/src/core/GameMode.cc

    r2843 r2848  
    2121 *
    2222 *   Author:
    23  *      Fabian 'x3n' Landau
    2423 *      Reto Grieder
    2524 *   Co-authors:
     
    3029/**
    3130    @file
    32     @brief Implementation of the Core class.
     31    @brief Implementation of the GameMode class.
    3332*/
    3433
    35 #include "Core.h"
    36 
    37 #include <cassert>
    38 #include <fstream>
    39 #include <cstdlib>
    40 #include <cstdio>
    41 #include <boost/filesystem.hpp>
    42 
    43 #ifdef ORXONOX_PLATFORM_WINDOWS
    44 #  ifndef WIN32_LEAN_AND_MEAN
    45 #    define WIN32_LEAN_AND_MEAN
    46 #  endif
    47 #  include <windows.h>
    48 #elif defined(ORXONOX_PLATFORM_APPLE)
    49 #  include <sys/param.h>
    50 #  include <mach-o/dyld.h>
    51 #else /* Linux */
    52 #  include <sys/types.h>
    53 #  include <unistd.h>
    54 #endif
    55 
    56 #include "SpecialConfig.h"
    57 #include "util/Debug.h"
    58 #include "util/Exception.h"
    59 #include "util/SignalHandler.h"
    60 #include "Clock.h"
    61 #include "CommandExecutor.h"
    62 #include "CommandLine.h"
    63 #include "ConfigFileManager.h"
    64 #include "ConfigValueIncludes.h"
    65 #include "CoreIncludes.h"
    66 #include "Factory.h"
    67 #include "Identifier.h"
    68 #include "Language.h"
    69 #include "LuaBind.h"
    70 #include "Shell.h"
    71 #include "TclBind.h"
    72 #include "TclThreadManager.h"
     34#include "GameMode.h"
    7335
    7436namespace orxonox
    7537{
    76     //! Path to the parent directory of the ones above if program was installed with relativ pahts
    77     static boost::filesystem::path rootPath_g;
    78     static boost::filesystem::path executablePath_g;            //!< Path to the executable
    79     static boost::filesystem::path mediaPath_g;                 //!< Path to the media file folder
    80     static boost::filesystem::path configPath_g;                //!< Path to the config file folder
    81     static boost::filesystem::path logPath_g;                   //!< Path to the log file folder
    82 
    83     bool Core::bShowsGraphics_s = false;
    84     bool Core::bHasServer_s     = false;
    85     bool Core::bIsClient_s      = false;
    86     bool Core::bIsStandalone_s  = false;
    87     bool Core::bIsMaster_s      = false;
    88 
    89     Core* Core::singletonRef_s  = 0;
    90 
    91     SetCommandLineArgument(mediaPath, "").information("PATH");
    92     SetCommandLineArgument(writingPathSuffix, "").information("DIR");
    93     SetCommandLineArgument(settingsFile, "orxonox.ini");
    94     SetCommandLineArgument(limitToCPU, 0).information("0: off | #cpu");
    95 
    96     Core::Core()
    97     {
    98         RegisterRootObject(Core);
    99 
    100         assert(Core::singletonRef_s == 0);
    101         Core::singletonRef_s = this;
    102     }
    103 
    104     Clock* Core::initialise(int argc, char** argv)
    105     {
    106         // Set up a basic clock to keep time
    107         this->gameClock_ = new Clock();
    108 
    109         // Parse command line arguments fist
    110         try
    111         {
    112             CommandLine::parseAll(argc, argv);
    113         }
    114         catch (ArgumentException& ex)
    115         {
    116             COUT(1) << ex.what() << std::endl;
    117             COUT(0) << "Usage:" << std::endl << "orxonox " << CommandLine::getUsageInformation() << std::endl;
    118         }
    119 
    120         // limit the main thread to the first core so that QueryPerformanceCounter doesn't jump
    121         // do this after ogre has initialised. Somehow Ogre changes the settings again (not through
    122         // the timer though).
    123         int limitToCPU = CommandLine::getValue("limitToCPU");
    124         if (limitToCPU > 0)
    125             setThreadAffinity((unsigned int)limitToCPU);
    126 
    127         // Determine and set the location of the executable
    128         setExecutablePath();
    129 
    130         // Determine whether we have an installed or a binary dir run
    131         // The latter occurs when simply running from the build directory
    132         checkDevBuild();
    133 
    134         // Make sure the directories we write in exist or else make them
    135         createDirectories();
    136 
    137         // create a signal handler (only active for linux)
    138         // This call is placed as soon as possible, but after the directories are set
    139         this->signalHandler_ = new SignalHandler();
    140         this->signalHandler_->doCatch(executablePath_g.string(), Core::getLogPathString() + "orxonox_crash.log");
    141 
    142         // Set the correct log path. Before this call, /tmp (Unix) or %TEMP% was used
    143         OutputHandler::getOutStream().setLogPath(Core::getLogPathString());
    144 
    145         // Manage ini files and set the default settings file (usually orxonox.ini)
    146         this->configFileManager_ = new ConfigFileManager();
    147         this->configFileManager_->setFilename(ConfigFileType::Settings,
    148             CommandLine::getValue("settingsFile").getString());
    149 
    150         this->languageInstance_ = new Language();
    151 
    152         // Do this soon after the ConfigFileManager has been created to open up the
    153         // possibility to configure everything below here
    154         this->setConfigValues();
    155 
    156         // Possible media path override by the command line
    157         if (!CommandLine::getArgument("mediaPath")->hasDefaultValue())
    158         {
    159             //std::string mediaPath = CommandLine::getValue("mediaPath");
    160             Core::tsetMediaPath(CommandLine::getValue("mediaPath"));
    161         }
    162 
    163         // Create the lua interface
    164         this->luaBind_ = new LuaBind();
    165 
    166         // initialise Tcl
    167         this->tclBind_ = new TclBind(Core::getMediaPathString());
    168         this->tclThreadManager_ = new TclThreadManager(tclBind_->getTclInterpreter());
    169 
    170         // create a shell
    171         this->shell_ = new Shell();
    172 
    173         // creates the class hierarchy for all classes with factories
    174         Factory::createClassHierarchy();
    175        
    176         this->loaded_ = true;
    177 
    178         // Return non const pointer to the game's clock for the main loop
    179         return this->gameClock_;
    180     }
    181 
    182     /**
    183         @brief Sets the bool to true to avoid static functions accessing a deleted object.
    184     */
    185     Core::~Core()
    186     {
    187         this->loaded_ = false;
    188 
    189         delete this->shell_;
    190         delete this->tclThreadManager_;
    191         delete this->tclBind_;
    192         delete this->luaBind_;
    193         delete this->languageInstance_;
    194         delete this->configFileManager_;
    195         delete this->signalHandler_;
    196 
    197         // Destroy command line arguments
    198         CommandLine::destroyAllArguments();
    199         // Also delete external console command that don't belong to an Identifier
    200         CommandExecutor::destroyExternalCommands();
    201 
    202         delete this->gameClock_;
    203 
    204         assert(Core::singletonRef_s);
    205         Core::singletonRef_s = 0;
    206     }
    207 
    208     /**
    209         @brief Function to collect the SetConfigValue-macro calls.
    210     */
    211     void Core::setConfigValues()
    212     {
    213 #ifdef NDEBUG
    214         const unsigned int defaultLevelConsole = 1;
    215         const unsigned int defaultLevelLogfile = 3;
    216         const unsigned int defaultLevelShell   = 1;
    217 #else
    218         const unsigned int defaultLevelConsole = 3;
    219         const unsigned int defaultLevelLogfile = 4;
    220         const unsigned int defaultLevelShell   = 3;
    221 #endif
    222         SetConfigValue(softDebugLevelConsole_, defaultLevelConsole)
    223             .description("The maximal level of debug output shown in the console").callback(this, &Core::debugLevelChanged);
    224         SetConfigValue(softDebugLevelLogfile_, defaultLevelLogfile)
    225             .description("The maximal level of debug output shown in the logfile").callback(this, &Core::debugLevelChanged);
    226         SetConfigValue(softDebugLevelShell_, defaultLevelShell)
    227             .description("The maximal level of debug output shown in the ingame shell").callback(this, &Core::debugLevelChanged);
    228 
    229         SetConfigValue(language_, Language::getLanguage().defaultLanguage_).description("The language of the ingame text").callback(this, &Core::languageChanged);
    230         SetConfigValue(bInitializeRandomNumberGenerator_, true).description("If true, all random actions are different each time you start the game").callback(this, &Core::initializeRandomNumberGenerator);
    231 
    232         SetConfigValue(mediaPathString_, mediaPath_g.string())
    233             .description("Relative path to the game data.").callback(this, &Core::mediaPathChanged);
    234     }
    235 
    236     /**
    237         @brief Callback function if the debug level has changed.
    238     */
    239     void Core::debugLevelChanged()
    240     {
    241         // softDebugLevel_ is the maximum of the 3 variables
    242         this->softDebugLevel_ = this->softDebugLevelConsole_;
    243         if (this->softDebugLevelLogfile_ > this->softDebugLevel_)
    244             this->softDebugLevel_ = this->softDebugLevelLogfile_;
    245         if (this->softDebugLevelShell_ > this->softDebugLevel_)
    246             this->softDebugLevel_ = this->softDebugLevelShell_;
    247 
    248         OutputHandler::setSoftDebugLevel(OutputHandler::LD_All,     this->softDebugLevel_);
    249         OutputHandler::setSoftDebugLevel(OutputHandler::LD_Console, this->softDebugLevelConsole_);
    250         OutputHandler::setSoftDebugLevel(OutputHandler::LD_Logfile, this->softDebugLevelLogfile_);
    251         OutputHandler::setSoftDebugLevel(OutputHandler::LD_Shell,   this->softDebugLevelShell_);
    252     }
    253 
    254     /**
    255         @brief Callback function if the language has changed.
    256     */
    257     void Core::languageChanged()
    258     {
    259         // Read the translation file after the language was configured
    260         Language::getLanguage().readTranslatedLanguageFile();
    261     }
    262 
    263     /**
    264     @brief
    265         Callback function if the media path has changed.
    266     */
    267     void Core::mediaPathChanged()
    268     {
    269         mediaPath_g = boost::filesystem::path(this->mediaPathString_);
    270     }
    271 
    272     /**
    273         @brief Returns the softDebugLevel for the given device (returns a default-value if the class ist right about to be created).
    274         @param device The device
    275         @return The softDebugLevel
    276     */
    277     int Core::getSoftDebugLevel(OutputHandler::OutputDevice device)
    278     {
    279         switch (device)
    280         {
    281         case OutputHandler::LD_All:
    282             return Core::getInstance().softDebugLevel_;
    283         case OutputHandler::LD_Console:
    284             return Core::getInstance().softDebugLevelConsole_;
    285         case OutputHandler::LD_Logfile:
    286             return Core::getInstance().softDebugLevelLogfile_;
    287         case OutputHandler::LD_Shell:
    288             return Core::getInstance().softDebugLevelShell_;
    289         default:
    290             assert(0);
    291             return 2;
    292         }
    293     }
    294 
    295      /**
    296         @brief Sets the softDebugLevel for the given device. Please use this only temporary and restore the value afterwards, as it overrides the configured value.
    297         @param device The device
    298         @param level The level
    299     */
    300      void Core::setSoftDebugLevel(OutputHandler::OutputDevice device, int level)
    301      {
    302         if (device == OutputHandler::LD_All)
    303             Core::getInstance().softDebugLevel_ = level;
    304         else if (device == OutputHandler::LD_Console)
    305             Core::getInstance().softDebugLevelConsole_ = level;
    306         else if (device == OutputHandler::LD_Logfile)
    307             Core::getInstance().softDebugLevelLogfile_ = level;
    308         else if (device == OutputHandler::LD_Shell)
    309             Core::getInstance().softDebugLevelShell_ = level;
    310 
    311         OutputHandler::setSoftDebugLevel(device, level);
    312      }
    313 
    314     /**
    315         @brief Returns the configured language.
    316     */
    317     const std::string& Core::getLanguage()
    318     {
    319         return Core::getInstance().language_;
    320     }
    321 
    322     /**
    323         @brief Sets the language in the config-file back to the default.
    324     */
    325     void Core::resetLanguage()
    326     {
    327         Core::getInstance().resetLanguageIntern();
    328     }
    329 
    330     /**
    331         @brief Sets the language in the config-file back to the default.
    332     */
    333     void Core::resetLanguageIntern()
    334     {
    335         ResetConfigValue(language_);
    336     }
    337 
    338     /**
    339     @brief
    340         Temporary sets the media path
    341     @param path
    342         The new media path
    343     */
    344     void Core::_tsetMediaPath(const std::string& path)
    345     {
    346         ModifyConfigValue(mediaPathString_, tset, path);
    347     }
    348 
    349     /*static*/ const boost::filesystem::path& Core::getMediaPath()
    350     {
    351         return mediaPath_g;
    352     }
    353     /*static*/ std::string Core::getMediaPathString()
    354     {
    355         return mediaPath_g.string() + '/';
    356     }
    357 
    358     /*static*/ const boost::filesystem::path& Core::getConfigPath()
    359     {
    360         return configPath_g;
    361     }
    362     /*static*/ std::string Core::getConfigPathString()
    363     {
    364         return configPath_g.string() + '/';
    365     }
    366 
    367     /*static*/ const boost::filesystem::path& Core::getLogPath()
    368     {
    369         return logPath_g;
    370     }
    371     /*static*/ std::string Core::getLogPathString()
    372     {
    373         return logPath_g.string() + '/';
    374     }
    375 
    376     void Core::initializeRandomNumberGenerator()
    377     {
    378         static bool bInitialized = false;
    379         if (!bInitialized && this->bInitializeRandomNumberGenerator_)
    380         {
    381             srand(time(0));
    382             rand();
    383             bInitialized = true;
    384         }
    385     }
    386 
    387 
    388     /**
    389     @note
    390         The code of this function has been copied and adjusted from OGRE, an open source graphics engine.
    391             (Object-oriented Graphics Rendering Engine)
    392         For the latest info, see http://www.ogre3d.org/
    393 
    394         Copyright (c) 2000-2008 Torus Knot Software Ltd
    395 
    396         OGRE is licensed under the LGPL. For more info, see OGRE license.
    397     */
    398     void Core::setThreadAffinity(int limitToCPU)
    399     {
    400         if (limitToCPU <= 0)
    401             return;
    402 
    403 #ifdef ORXONOX_PLATFORM_WINDOWS
    404         unsigned int coreNr = limitToCPU - 1;
    405         // Get the current process core mask
    406         DWORD procMask;
    407         DWORD sysMask;
    408 #  if _MSC_VER >= 1400 && defined (_M_X64)
    409         GetProcessAffinityMask(GetCurrentProcess(), (PDWORD_PTR)&procMask, (PDWORD_PTR)&sysMask);
    410 #  else
    411         GetProcessAffinityMask(GetCurrentProcess(), &procMask, &sysMask);
    412 #  endif
    413 
    414         // If procMask is 0, consider there is only one core available
    415         // (using 0 as procMask will cause an infinite loop below)
    416         if (procMask == 0)
    417             procMask = 1;
    418 
    419         // if the core specified with coreNr is not available, take the lowest one
    420         if (!(procMask & (1 << coreNr)))
    421             coreNr = 0;
    422 
    423         // Find the lowest core that this process uses and coreNr suggests
    424         DWORD threadMask = 1;
    425         while ((threadMask & procMask) == 0 || (threadMask < (1u << coreNr)))
    426             threadMask <<= 1;
    427 
    428         // Set affinity to the first core
    429         SetThreadAffinityMask(GetCurrentThread(), threadMask);
    430 #endif
    431     }
    432 
    433     /**
    434     @brief
    435         Compares the executable path with the working directory
    436     */
    437     void Core::setExecutablePath()
    438     {
    439 #ifdef ORXONOX_PLATFORM_WINDOWS
    440         // get executable module
    441         TCHAR buffer[1024];
    442         if (GetModuleFileName(NULL, buffer, 1024) == 0)
    443             ThrowException(General, "Could not retrieve executable path.");
    444 
    445 #elif defined(ORXONOX_PLATFORM_APPLE)
    446         char buffer[1024];
    447         unsigned long path_len = 1023;
    448         if (_NSGetExecutablePath(buffer, &path_len))
    449             ThrowException(General, "Could not retrieve executable path.");
    450 
    451 #else /* Linux */
    452         /* written by Nicolai Haehnle <prefect_@gmx.net> */
    453 
    454         /* Get our PID and build the name of the link in /proc */
    455         char linkname[64]; /* /proc/<pid>/exe */
    456         if (snprintf(linkname, sizeof(linkname), "/proc/%i/exe", getpid()) < 0)
    457         {
    458             /* This should only happen on large word systems. I'm not sure
    459                what the proper response is here.
    460                Since it really is an assert-like condition, aborting the
    461                program seems to be in order. */
    462             assert(false);
    463         }
    464 
    465         /* Now read the symbolic link */
    466         char buffer[1024];
    467         int ret;
    468         ret = readlink(linkname, buffer, 1024);
    469         /* In case of an error, leave the handling up to the caller */
    470         if (ret == -1)
    471             ThrowException(General, "Could not retrieve executable path.");
    472 
    473         /* Ensure proper NUL termination */
    474         buffer[ret] = 0;
    475 #endif
    476 
    477         executablePath_g = boost::filesystem::path(buffer);
    478 #ifndef ORXONOX_PLATFORM_APPLE
    479         executablePath_g = executablePath_g.branch_path(); // remove executable name
    480 #endif
    481     }
    482 
    483     /**
    484     @brief
    485         Checks for "orxonox_dev_build.keep_me" in the executable diretory.
    486         If found it means that this is not an installed run, hence we
    487         don't write the logs and config files to ~/.orxonox
    488     */
    489     void Core::checkDevBuild()
    490     {
    491         if (boost::filesystem::exists(executablePath_g / "orxonox_dev_build.keep_me"))
    492         {
    493             COUT(1) << "Running from the build tree." << std::endl;
    494             Core::isDevBuild_ = true;
    495             mediaPath_g  = ORXONOX_MEDIA_DEV_PATH;
    496             configPath_g = ORXONOX_CONFIG_DEV_PATH;
    497             logPath_g    = ORXONOX_LOG_DEV_PATH;
    498         }
    499         else
    500         {
    501 #ifdef INSTALL_COPYABLE // --> relative paths
    502             // Also set the root path
    503             boost::filesystem::path relativeExecutablePath(ORXONOX_RUNTIME_INSTALL_PATH);
    504             rootPath_g = executablePath_g;
    505             while (!boost::filesystem::equivalent(rootPath_g / relativeExecutablePath, executablePath_g) || rootPath_g.empty())
    506                 rootPath_g = rootPath_g.branch_path();
    507             if (rootPath_g.empty())
    508                 ThrowException(General, "Could not derive a root directory. Might the binary installation directory contain '..' when taken relative to the installation prefix path?");
    509 
    510             // Using paths relative to the install prefix, complete them
    511             mediaPath_g  = rootPath_g / ORXONOX_MEDIA_INSTALL_PATH;
    512             configPath_g = rootPath_g / ORXONOX_CONFIG_INSTALL_PATH;
    513             logPath_g    = rootPath_g / ORXONOX_LOG_INSTALL_PATH;
    514 #else
    515             // There is no root path, so don't set it at all
    516 
    517             mediaPath_g  = ORXONOX_MEDIA_INSTALL_PATH;
    518 
    519             // Get user directory
    520 #  ifdef ORXONOX_PLATFORM_UNIX /* Apple? */
    521             char* userDataPathPtr(getenv("HOME"));
    522 #  else
    523             char* userDataPathPtr(getenv("APPDATA"));
    524 #  endif
    525             if (userDataPathPtr == NULL)
    526                 ThrowException(General, "Could not retrieve user data path.");
    527             boost::filesystem::path userDataPath(userDataPathPtr);
    528             userDataPath /= ".orxonox";
    529 
    530             configPath_g = userDataPath / ORXONOX_CONFIG_INSTALL_PATH;
    531             logPath_g    = userDataPath / ORXONOX_LOG_INSTALL_PATH;
    532 #endif
    533         }
    534 
    535         // Option to put all the config and log files in a separate folder
    536         if (!CommandLine::getArgument("writingPathSuffix")->hasDefaultValue())
    537         {
    538             std::string directory(CommandLine::getValue("writingPathSuffix").getString());
    539             configPath_g = configPath_g / directory;
    540             logPath_g    = logPath_g    / directory;
    541         }
    542     }
    543 
    544     /*
    545     @brief
    546         Checks for the log and the config directory and creates them
    547         if necessary. Otherwise me might have problems opening those files.
    548     */
    549     void Core::createDirectories()
    550     {
    551         std::vector<std::pair<boost::filesystem::path, std::string> > directories;
    552         directories.push_back(std::pair<boost::filesystem::path, std::string>
    553             (boost::filesystem::path(configPath_g), "config"));
    554         directories.push_back(std::pair<boost::filesystem::path, std::string>
    555             (boost::filesystem::path(logPath_g),    "log"));
    556 
    557         for (std::vector<std::pair<boost::filesystem::path, std::string> >::iterator it = directories.begin();
    558             it != directories.end(); ++it)
    559         {
    560             if (boost::filesystem::exists(it->first) && !boost::filesystem::is_directory(it->first))
    561             {
    562                 ThrowException(General, std::string("The ") + it->second + " directory has been preoccupied by a file! \
    563                                          Please remove " + it->first.string());
    564             }
    565             if (boost::filesystem::create_directories(it->first)) // function may not return true at all (bug?)
    566             {
    567                 COUT(4) << "Created " << it->second << " directory" << std::endl;
    568             }
    569         }
    570     }
    571 
    572     void Core::update(const Clock& time)
    573     {
    574         this->tclThreadManager_->update(time);
    575     }
     38    bool GameMode::bShowsGraphics_s = false;
     39    bool GameMode::bHasServer_s     = false;
     40    bool GameMode::bIsClient_s      = false;
     41    bool GameMode::bIsStandalone_s  = false;
     42    bool GameMode::bIsMaster_s      = false;
    57643}
  • code/branches/gui/src/core/GameMode.h

    r2843 r2848  
    2121 *
    2222 *   Author:
    23  *      Fabian 'x3n' Landau
    2423 *      Reto Grieder
    2524 *   Co-authors:
     
    3029/**
    3130    @file
    32     @brief Declaration of the Core class.
    33 
    34     The Core class is a singleton, only used to configure some variables
    35     in the core through the config-file.
     31    @brief Declaration of the GameMode class.
    3632*/
    3733
    38 #ifndef _Core_H__
    39 #define _Core_H__
     34#ifndef _GameMode_H__
     35#define _GameMode_H__
    4036
    4137#include "CorePrereqs.h"
    4238
    43 #include <cassert>
    44 #include "OrxonoxClass.h"
    45 #include "util/OutputHandler.h"
    46 
    47 // Only allow main to access postMainInitialisation, so we need a forward declaration
    48 int main(int, char**);
    49 // boost::filesystem header has quite a large tail, use forward declaration
    50 namespace boost { namespace filesystem
    51 {
    52     struct path_traits;
    53     template<class String, class Traits> class basic_path;
    54     typedef basic_path< std::string, path_traits> path;
    55 } }
    56 
    5739namespace orxonox
    5840{
    59     //! The Core class is a singleton, only used to configure some config-values.
    60     class _CoreExport Core : public OrxonoxClass
     41    class _CoreExport GameMode
    6142    {
    6243        public:
    63             Core();
    64             ~Core();
    65 
    66             Clock* initialise(int argc, char** argv);
    67             void setConfigValues();
    68 
    69             void update(const Clock& time);
    70 
    71             static Core& getInstance() { assert(Core::singletonRef_s); return *Core::singletonRef_s; }
    72 
    73             static int   getSoftDebugLevel(OutputHandler::OutputDevice device = OutputHandler::LD_All);
    74             static void  setSoftDebugLevel(OutputHandler::OutputDevice device, int level);
    75             static const std::string& getLanguage();
    76             static void  resetLanguage();
    77 
    78             static const Clock& getGameClock() { return *getInstance().gameClock_; }
    79 
    80             static void tsetMediaPath(const std::string& path)
    81             { assert(singletonRef_s); singletonRef_s->_tsetMediaPath(path); }
    82             static const boost::filesystem::path& getMediaPath();
    83             static const boost::filesystem::path& getConfigPath();
    84             static const boost::filesystem::path& getLogPath();
    85             static std::string getMediaPathString();
    86             static std::string getConfigPathString();
    87             static std::string getLogPathString();
    88 
    89             // fast access global variables.
    9044            static bool showsGraphics() { return bShowsGraphics_s; }
    9145            static bool hasServer()     { return bHasServer_s; }
     
    10054
    10155        private:
    102             Core(const Core&);
    103 
    104             void checkDevBuild();
    105             void setExecutablePath();
    106             void createDirectories();
    107             void setThreadAffinity(int limitToCPU);
    108 
    109             void resetLanguageIntern();
    110             void initializeRandomNumberGenerator();
    111             void debugLevelChanged();
    112             void languageChanged();
    113             void mediaPathChanged();
    114             void _tsetMediaPath(const std::string& path);
    115 
    116             // Singletons
    117             ConfigFileManager*    configFileManager_;
    118             Language*             languageInstance_;
    119             LuaBind*              luaBind_;
    120             Shell*                shell_;
    121             SignalHandler*        signalHandler_;
    122             TclBind*              tclBind_;
    123             TclThreadManager*     tclThreadManager_;
    124 
    125             Clock*                gameClock_;
    126 
    127             int softDebugLevel_;                            //!< The debug level
    128             int softDebugLevelConsole_;                     //!< The debug level for the console
    129             int softDebugLevelLogfile_;                     //!< The debug level for the logfile
    130             int softDebugLevelShell_;                       //!< The debug level for the ingame shell
    131             std::string language_;                          //!< The language
    132             bool bInitializeRandomNumberGenerator_;         //!< If true, srand(time(0)) is called
    133             std::string mediaPathString_;                   //!< Path to the data/media file folder as string
    134             bool isDevBuild_;                               //!< True for builds in the build directory (not installed)
    135             bool loaded_;                                   //!< Only true if constructor was interrupted
     56            GameMode();
     57            GameMode(const GameMode& inst);
     58            ~GameMode();
    13659
    13760            static bool bShowsGraphics_s;                   //!< global variable that tells whether to show graphics
     
    14063            static bool bIsStandalone_s;
    14164            static bool bIsMaster_s;
    142 
    143             static Core* singletonRef_s;
    14465    };
    14566}
    14667
    147 #endif /* _Core_H__ */
     68#endif /* _GameMode_H__ */
  • code/branches/gui/src/network/ClientConnectionListener.cc

    r2846 r2848  
    2929#include "ClientConnectionListener.h"
    3030#include "core/CoreIncludes.h"
    31 #include "core/Core.h"
     31#include "core/GameMode.h"
    3232
    3333namespace orxonox{
     
    3939
    4040  void ClientConnectionListener::getConnectedClients(){
    41     if(Core::showsGraphics())
     41    if(GameMode::showsGraphics())
    4242      this->clientConnected(0); //server client id
    4343    ClientInformation *client = ClientInformation::getBegin();
  • code/branches/gui/src/network/packet/Gamestate.cc

    r2773 r2848  
    3434#include "../synchronisable/Synchronisable.h"
    3535#include "../TrafficControl.h"
    36 #include "core/Core.h"
     36#include "core/GameMode.h"
    3737#include "core/CoreIncludes.h"
    3838#include "core/Iterator.h"
     
    162162    if(!s)
    163163    {
    164       if (!Core::isMaster())
     164      if (!GameMode::isMaster())
    165165      {
    166166        Synchronisable::fabricate(mem, mode);
  • code/branches/gui/src/network/synchronisable/SynchronisableVariable.cc

    r2798 r2848  
    3030#include <cstring>
    3131#include "util/Math.h"
    32 #include "core/Core.h"
     32#include "core/GameMode.h"
    3333
    3434
     
    4141  if ( state_ == 0x0 )
    4242  {
    43     state_ = Core::isMaster() ? 0x1 : 0x2;  // set the appropriate mode here
     43    state_ = GameMode::isMaster() ? 0x1 : 0x2;  // set the appropriate mode here
    4444  }
    4545}
  • code/branches/gui/src/orxonox/CameraManager.cc

    r2834 r2848  
    3535#include <OgreResource.h>
    3636
    37 #include "core/Core.h"
     37#include "core/GameMode.h"
    3838#include "core/Iterator.h"
    3939#include "objects/worldentities/Camera.h"
     
    7575    void CameraManager::requestFocus(Camera* camera)
    7676    {
    77         if (!Core::showsGraphics())
     77        if (!GameMode::showsGraphics())
    7878            return;
    7979
     
    100100    void CameraManager::releaseFocus(Camera* camera)
    101101    {
    102         if (!Core::showsGraphics())
     102        if (!GameMode::showsGraphics())
    103103            return;
    104104
  • code/branches/gui/src/orxonox/GraphicsManager.cc

    r2842 r2848  
    6262#include "core/CoreIncludes.h"
    6363#include "core/Core.h"
     64#include "core/GameMode.h"
    6465#include "tools/WindowEventListener.h"
    6566#include "tools/ParticleInterface.h"
     
    102103    void GraphicsManager::initialise()
    103104    {
    104         Core::setShowsGraphics(true);
    105 
    106105        // Ogre setup procedure
    107106        setupOgre();
     
    156155            this->ogreLogger_->destroyLog(Ogre::LogManager::getSingleton().getDefaultLog());
    157156            delete this->ogreLogger_;
    158 
    159             // Don't showing graphics anymore
    160             Core::setShowsGraphics(false);
    161157        }
    162158
  • code/branches/gui/src/orxonox/PlayerManager.cc

    r2662 r2848  
    3131
    3232#include "LevelManager.h"
    33 #include "core/Core.h"
     33#include "core/GameMode.h"
    3434#include "core/CoreIncludes.h"
    3535#include "objects/Level.h"
     
    5858    void PlayerManager::clientConnected(unsigned int clientID)
    5959    {
    60         if (Core::isMaster())
     60        if (GameMode::isMaster())
    6161        {
    6262            COUT(3) << "client connected" << std::endl;
     
    7777    void PlayerManager::clientDisconnected(unsigned int clientID)
    7878    {
    79         if (Core::isMaster())
     79        if (GameMode::isMaster())
    8080        {
    8181            COUT(3) << "client disconnected" << std::endl;
     
    9797    PlayerInfo* PlayerManager::getClient(unsigned int clientID) const
    9898    {
    99         if (Core::isMaster())
     99        if (GameMode::isMaster())
    100100        {
    101101            std::map<unsigned int, PlayerInfo*>::const_iterator it = this->clients_.find(clientID);
  • code/branches/gui/src/orxonox/gamestates/GSClient.cc

    r2846 r2848  
    3333#include "core/Clock.h"
    3434#include "core/CommandLine.h"
    35 #include "core/Core.h"
     35#include "core/Game.h"
     36#include "core/GameMode.h"
    3637#include "network/Client.h"
    37 #include "core/Game.h"
    3838
    3939namespace orxonox
     
    5555    void GSClient::activate()
    5656    {
    57         Core::setIsClient(true);
     57        GameMode::setIsClient(true);
    5858
    5959        this->client_ = new Client(CommandLine::getValue("ip").getString(), CommandLine::getValue("port"));
     
    7272        delete this->client_;
    7373
    74         Core::setIsClient(false);
     74        GameMode::setIsClient(false);
    7575    }
    7676
  • code/branches/gui/src/orxonox/gamestates/GSDedicated.cc

    r2844 r2848  
    3232#include "core/Clock.h"
    3333#include "core/CommandLine.h"
    34 #include "core/Core.h"
     34#include "core/Game.h"
     35#include "core/GameMode.h"
    3536#include "core/Iterator.h"
    3637#include "network/Server.h"
    3738#include "objects/Tickable.h"
    3839#include "util/Sleep.h"
    39 #include "core/Game.h"
    4040
    4141namespace orxonox
     
    5656    void GSDedicated::activate()
    5757    {
    58         Core::setHasServer(true);
     58        GameMode::setHasServer(true);
    5959
    6060        this->server_ = new Server(CommandLine::getValue("port"));
     
    6969        delete this->server_;
    7070
    71         Core::setHasServer(false);
     71        GameMode::setHasServer(false);
    7272    }
    7373
  • code/branches/gui/src/orxonox/gamestates/GSGUI.cc

    r2845 r2848  
    3333#include "core/Clock.h"
    3434#include "core/ConsoleCommand.h"
     35#include "core/Game.h"
    3536#include "core/input/InputManager.h"
    3637#include "core/input/SimpleInputState.h"
    3738#include "gui/GUIManager.h"
    3839#include "GraphicsManager.h"
    39 #include "core/Game.h"
    4040
    4141namespace orxonox
  • code/branches/gui/src/orxonox/gamestates/GSGraphics.cc

    r2847 r2848  
    3838#include "core/CoreIncludes.h"
    3939#include "core/Game.h"
     40#include "core/GameMode.h"
    4041#include "core/input/InputManager.h"
    4142#include "core/input/KeyBinder.h"
     
    7475    void GSGraphics::activate()
    7576    {
    76         Core::setShowsGraphics(true);
     77        GameMode::setShowsGraphics(true);
    7778
    7879        setConfigValues();
     
    128129        delete graphicsManager_;
    129130
    130         Core::setShowsGraphics(false);
     131        GameMode::setShowsGraphics(false);
    131132    }
    132133
  • code/branches/gui/src/orxonox/gamestates/GSLevel.cc

    r2844 r2848  
    3939#include "core/CommandLine.h"
    4040#include "core/ConfigValueIncludes.h"
     41#include "core/Core.h"
    4142#include "core/CoreIncludes.h"
    42 #include "core/Core.h"
     43#include "core/Game.h"
     44#include "core/GameMode.h"
    4345#include "objects/Tickable.h"
    4446#include "objects/Radar.h"
     
    4749#include "LevelManager.h"
    4850#include "PlayerManager.h"
    49 #include "core/Game.h"
    5051
    5152namespace orxonox
     
    8384        setConfigValues();
    8485
    85         if (Core::showsGraphics())
     86        if (GameMode::showsGraphics())
    8687        {
    8788            inputState_ = InputManager::getInstance().createInputState<SimpleInputState>("game");
     
    99100        this->playerManager_ = new PlayerManager();
    100101
    101         if (Core::isMaster())
     102        if (GameMode::isMaster())
    102103        {
    103104            // create the global LevelManager
     
    107108        }
    108109
    109         if (Core::showsGraphics())
     110        if (GameMode::showsGraphics())
    110111        {
    111112            // TODO: insert slomo console command with
     
    149150        //Loader::close();
    150151
    151         if (Core::showsGraphics())
     152        if (GameMode::showsGraphics())
    152153            InputManager::getInstance().requestLeaveState("game");
    153154
    154         if (Core::isMaster())
     155        if (GameMode::isMaster())
    155156            this->unloadLevel();
    156157
     
    179180        }
    180181
    181         if (Core::showsGraphics())
     182        if (GameMode::showsGraphics())
    182183        {
    183184            inputState_->setHandler(0);
     
    240241    void GSLevel::keybindInternal(const std::string& command, bool bTemporary)
    241242    {
    242         if (Core::showsGraphics())
     243        if (GameMode::showsGraphics())
    243244        {
    244245            static std::string bindingString = "";
  • code/branches/gui/src/orxonox/gamestates/GSRoot.cc

    r2846 r2848  
    3333#include "util/Debug.h"
    3434#include "core/Clock.h"
    35 #include "core/Core.h"
     35#include "core/Game.h"
     36#include "core/GameMode.h"
    3637#include "core/CommandLine.h"
    3738#include "core/ConsoleCommand.h"
     
    3940#include "tools/Timer.h"
    4041#include "objects/Tickable.h"
    41 #include "core/Game.h"
    4242
    4343namespace orxonox
     
    142142    void GSRoot::setTimeFactor(float factor)
    143143    {
    144         if (Core::isMaster())
     144        if (GameMode::isMaster())
    145145        {
    146146            if (!this->bPaused_)
     
    160160    void GSRoot::pause()
    161161    {
    162         if (Core::isMaster())
     162        if (GameMode::isMaster())
    163163        {
    164164            if (!this->bPaused_)
  • code/branches/gui/src/orxonox/gamestates/GSServer.cc

    r2844 r2848  
    3131
    3232#include "core/CommandLine.h"
    33 #include "core/Core.h"
     33#include "core/Game.h"
     34#include "core/GameMode.h"
    3435#include "network/Server.h"
    35 #include "core/Game.h"
    3636
    3737namespace orxonox
     
    5353    void GSServer::activate()
    5454    {
    55         Core::setHasServer(true);
     55        GameMode::setHasServer(true);
    5656
    5757        this->server_ = new Server(CommandLine::getValue("port"));
     
    6666        delete this->server_;
    6767
    68         Core::setHasServer(false);
     68        GameMode::setHasServer(false);
    6969    }
    7070
  • code/branches/gui/src/orxonox/gamestates/GSStandalone.cc

    r2844 r2848  
    3232#include <OgreViewport.h>
    3333#include <OgreCamera.h>
    34 #include "core/Core.h"
     34#include "core/Game.h"
     35#include "core/GameMode.h"
    3536#include "core/ConsoleCommand.h"
    3637#include "gui/GUIManager.h"
    3738#include "GraphicsManager.h"
    38 #include "core/Game.h"
    3939
    4040namespace orxonox
     
    5454    void GSStandalone::activate()
    5555    {
    56         Core::setIsStandalone(true);
     56        GameMode::setIsStandalone(true);
    5757
    5858        guiManager_ = GUIManager::getInstancePtr();
     
    6363    void GSStandalone::deactivate()
    6464    {
    65         Core::setIsStandalone(false);
     65        GameMode::setIsStandalone(false);
    6666    }
    6767
  • code/branches/gui/src/orxonox/objects/Scene.cc

    r2662 r2848  
    4141
    4242#include "core/CoreIncludes.h"
    43 #include "core/Core.h"
     43#include "core/GameMode.h"
    4444#include "core/XMLPort.h"
    4545#include "tools/BulletConversions.h"
     
    5757        this->bShadows_ = true;
    5858
    59         if (Core::showsGraphics())
     59        if (GameMode::showsGraphics())
    6060        {
    6161            if (Ogre::Root::getSingletonPtr())
     
    9999                Ogre::Root::getSingleton().destroySceneManager(this->sceneManager_);
    100100            }
    101             else if (!Core::showsGraphics())
     101            else if (!GameMode::showsGraphics())
    102102            {
    103103                delete this->sceneManager_;
     
    227227    void Scene::tick(float dt)
    228228    {
    229         if (!Core::showsGraphics())
     229        if (!GameMode::showsGraphics())
    230230        {
    231231            // We need to update the scene nodes if we don't render
     
    256256    void Scene::setSkybox(const std::string& skybox)
    257257    {
    258         if (Core::showsGraphics() && this->sceneManager_)
     258        if (GameMode::showsGraphics() && this->sceneManager_)
    259259            this->sceneManager_->setSkyBox(true, skybox);
    260260
     
    264264    void Scene::setAmbientLight(const ColourValue& colour)
    265265    {
    266         if (Core::showsGraphics() && this->sceneManager_)
     266        if (GameMode::showsGraphics() && this->sceneManager_)
    267267            this->sceneManager_->setAmbientLight(colour);
    268268
     
    272272    void Scene::setShadow(bool bShadow)
    273273    {
    274         if (Core::showsGraphics() && this->sceneManager_)
     274        if (GameMode::showsGraphics() && this->sceneManager_)
    275275        {
    276276            if (bShadow)
  • code/branches/gui/src/orxonox/objects/controllers/AIController.cc

    r2662 r2848  
    3030#include "AIController.h"
    3131
    32 #include "core/Core.h"
     32#include "core/GameMode.h"
    3333#include "core/CoreIncludes.h"
    3434#include "core/Executor.h"
     
    4545        RegisterObject(AIController);
    4646
    47         if (Core::isMaster())
     47        if (GameMode::isMaster())
    4848            this->actionTimer_.setTimer(ACTION_INTERVAL, true, this, createExecutor(createFunctor(&AIController::action)));
    4949    }
  • code/branches/gui/src/orxonox/objects/gametypes/Gametype.cc

    r2710 r2848  
    3636#include "core/ConfigValueIncludes.h"
    3737#include "core/Template.h"
    38 #include "core/Core.h"
     38#include "core/GameMode.h"
    3939#include "overlays/OverlayGroup.h"
    4040#include "objects/infos/PlayerInfo.h"
     
    6969
    7070        // load the corresponding score board
    71         if (Core::showsGraphics() && this->scoreboardTemplate_ != "")
     71        if (GameMode::showsGraphics() && this->scoreboardTemplate_ != "")
    7272        {
    7373            this->scoreboard_ = new OverlayGroup(this);
  • code/branches/gui/src/orxonox/objects/infos/Bot.cc

    r2662 r2848  
    3030#include "Bot.h"
    3131
    32 #include "core/Core.h"
     32#include "core/GameMode.h"
    3333#include "core/CoreIncludes.h"
    3434#include "core/ConfigValueIncludes.h"
     
    4646
    4747        this->bHumanPlayer_ = false;
    48         this->bLocalPlayer_ = Core::isMaster();
     48        this->bLocalPlayer_ = GameMode::isMaster();
    4949        this->bSetUnreadyAfterSpawn_ = false;
    5050        this->setReadyToSpawn(true);
  • code/branches/gui/src/orxonox/objects/infos/HumanPlayer.cc

    r2662 r2848  
    3030#include "HumanPlayer.h"
    3131
    32 #include "core/Core.h"
     32#include "core/GameMode.h"
    3333#include "core/CoreIncludes.h"
    3434#include "core/ConfigValueIncludes.h"
     
    4747        RegisterObject(HumanPlayer);
    4848
    49         this->server_initialized_ = Core::isMaster();
     49        this->server_initialized_ = GameMode::isMaster();
    5050        this->client_initialized_ = false;
    5151
     
    8282            this->synchronize_nick_ = this->nick_;
    8383
    84             if (Core::isMaster())
     84            if (GameMode::isMaster())
    8585                this->setName(this->nick_);
    8686        }
     
    105105            this->client_initialized_ = true;
    106106
    107             if (!Core::isMaster())
     107            if (!GameMode::isMaster())
    108108                this->setObjectMode(objectDirection::bidirectional);
    109109            else
  • code/branches/gui/src/orxonox/objects/items/MultiStateEngine.cc

    r2782 r2848  
    3030#include "MultiStateEngine.h"
    3131
    32 #include "core/Core.h"
     32#include "core/GameMode.h"
    3333#include "core/CoreIncludes.h"
    3434#include "core/XMLPort.h"
     
    123123            }
    124124
    125             if (Core::isMaster())
     125            if (GameMode::isMaster())
    126126            {
    127127                for (std::list<WorldEntity*>::const_iterator it = this->activeEffects_.begin(); it != this->activeEffects_.end(); ++it)
  • code/branches/gui/src/orxonox/objects/weaponSystem/projectiles/BillboardProjectile.cc

    r2662 r2848  
    3232#include <OgreBillboardSet.h>
    3333
    34 #include "core/Core.h"
     34#include "core/GameMode.h"
    3535#include "core/CoreIncludes.h"
    3636#include "objects/Scene.h"
     
    4444        RegisterObject(BillboardProjectile);
    4545
    46         if (Core::showsGraphics())
     46        if (GameMode::showsGraphics())
    4747        {
    4848            assert(this->getScene()->getSceneManager()); // getScene() was already checked by WorldEntity
     
    5656    BillboardProjectile::~BillboardProjectile()
    5757    {
    58         if (this->isInitialized() && Core::showsGraphics() && this->billboard_.getBillboardSet())
     58        if (this->isInitialized() && GameMode::showsGraphics() && this->billboard_.getBillboardSet())
    5959            this->detachOgreObject(this->billboard_.getBillboardSet());
    6060    }
  • code/branches/gui/src/orxonox/objects/weaponSystem/projectiles/ParticleProjectile.cc

    r2662 r2848  
    3333#include <OgreParticleEmitter.h>
    3434
    35 #include "core/Core.h"
     35#include "core/GameMode.h"
    3636#include "core/CoreIncludes.h"
    3737#include "core/ConfigValueIncludes.h"
     
    4646        RegisterObject(ParticleProjectile);
    4747
    48         if (Core::showsGraphics())
     48        if (GameMode::showsGraphics())
    4949        {
    5050            this->particles_ = new ParticleInterface(this->getScene()->getSceneManager(), "Orxonox/shot3_small", LODParticle::normal);
  • code/branches/gui/src/orxonox/objects/weaponSystem/projectiles/Projectile.cc

    r2782 r2848  
    4141#include "objects/worldentities/ParticleSpawner.h"
    4242#include "objects/collisionshapes/SphereCollisionShape.h"
    43 #include "core/Core.h"
     43#include "core/GameMode.h"
    4444
    4545namespace orxonox
     
    5555        // Get notification about collisions
    5656
    57         if (Core::isMaster())
     57        if (GameMode::isMaster())
    5858        {
    5959            this->enableCollisionCallback();
     
    9393    void Projectile::destroyObject()
    9494    {
    95         if (Core::isMaster())
     95        if (GameMode::isMaster())
    9696            delete this;
    9797    }
     
    9999    bool Projectile::collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint)
    100100    {
    101         if (!this->bDestroy_ && Core::isMaster())
     101        if (!this->bDestroy_ && GameMode::isMaster())
    102102        {
    103103            this->bDestroy_ = true;
  • code/branches/gui/src/orxonox/objects/worldentities/Backlight.cc

    r2782 r2848  
    3333#include <OgreSceneManager.h>
    3434
    35 #include "core/Core.h"
     35#include "core/GameMode.h"
    3636#include "core/CoreIncludes.h"
    3737#include "core/Executor.h"
     
    5858        this->tickcount_ = 0;
    5959
    60         if (Core::showsGraphics())
     60        if (GameMode::showsGraphics())
    6161        {
    6262            if (!this->getScene())
  • code/branches/gui/src/orxonox/objects/worldentities/Billboard.cc

    r2662 r2848  
    3434#include "core/CoreIncludes.h"
    3535#include "core/XMLPort.h"
    36 #include "core/Core.h"
     36#include "core/GameMode.h"
    3737#include "objects/Scene.h"
    3838
     
    8181        if (!this->billboard_.getBillboardSet())
    8282        {
    83             if (this->getScene() && Core::showsGraphics())
     83            if (this->getScene() && GameMode::showsGraphics())
    8484            {
    8585                this->billboard_.setBillboardSet(this->getScene()->getSceneManager(), this->material_, this->colour_, 1);
     
    9898        {
    9999/*
    100             if (this->getScene() && Core::showsGraphics() && (this->material_ != ""))
     100            if (this->getScene() && GameMode::showsGraphics() && (this->material_ != ""))
    101101            {
    102102                this->billboard_.setBillboardSet(this->getScene()->getSceneManager(), this->material_, this->colour_, 1);
  • code/branches/gui/src/orxonox/objects/worldentities/BlinkingBillboard.cc

    r2662 r2848  
    3030#include "BlinkingBillboard.h"
    3131
    32 #include "core/Core.h"
     32#include "core/GameMode.h"
    3333#include "core/CoreIncludes.h"
    3434#include "core/XMLPort.h"
     
    7777        SUPER(BlinkingBillboard, tick, dt);
    7878
    79         if (Core::isMaster() && this->isActive())
     79        if (GameMode::isMaster() && this->isActive())
    8080        {
    8181            this->time_ += dt;
  • code/branches/gui/src/orxonox/objects/worldentities/ControllableEntity.cc

    r2662 r2848  
    3434#include "core/CoreIncludes.h"
    3535#include "core/ConfigValueIncludes.h"
    36 #include "core/Core.h"
     36#include "core/GameMode.h"
    3737#include "core/XMLPort.h"
    3838#include "core/Template.h"
     
    236236            this->startLocalHumanControl();
    237237
    238             if (!Core::isMaster())
     238            if (!GameMode::isMaster())
    239239            {
    240240                this->client_overwrite_ = this->server_overwrite_;
     
    331331            if (!this->isDynamic())
    332332            {
    333                 if (Core::isMaster())
     333                if (GameMode::isMaster())
    334334                {
    335335                    this->server_position_ = this->getPosition();
     
    446446    void ControllableEntity::setPosition(const Vector3& position)
    447447    {
    448         if (Core::isMaster())
     448        if (GameMode::isMaster())
    449449        {
    450450            MobileEntity::setPosition(position);
     
    461461    void ControllableEntity::setOrientation(const Quaternion& orientation)
    462462    {
    463         if (Core::isMaster())
     463        if (GameMode::isMaster())
    464464        {
    465465            MobileEntity::setOrientation(orientation);
     
    476476    void ControllableEntity::setVelocity(const Vector3& velocity)
    477477    {
    478         if (Core::isMaster())
     478        if (GameMode::isMaster())
    479479        {
    480480            MobileEntity::setVelocity(velocity);
     
    491491    void ControllableEntity::setAngularVelocity(const Vector3& velocity)
    492492    {
    493         if (Core::isMaster())
     493        if (GameMode::isMaster())
    494494        {
    495495            MobileEntity::setAngularVelocity(velocity);
     
    507507    {
    508508        MobileEntity::setWorldTransform(worldTrans);
    509         if (Core::isMaster())
     509        if (GameMode::isMaster())
    510510        {
    511511            this->server_position_ = this->getPosition();
  • code/branches/gui/src/orxonox/objects/worldentities/ExplosionChunk.cc

    r2759 r2848  
    3232#include <OgreParticleSystem.h>
    3333
    34 #include "core/Core.h"
     34#include "core/GameMode.h"
    3535#include "core/CoreIncludes.h"
    3636#include "core/Executor.h"
     
    4747        RegisterObject(ExplosionChunk);
    4848
    49         if ( Core::showsGraphics() && ( !this->getScene() || !this->getScene()->getSceneManager() ) )
     49        if ( GameMode::showsGraphics() && ( !this->getScene() || !this->getScene()->getSceneManager() ) )
    5050            ThrowException(AbortLoading, "Can't create ExplosionChunk, no scene or no scene manager given.");
    5151
     
    5353        this->LOD_ = LODParticle::normal;
    5454
    55         if ( Core::showsGraphics() )
     55        if ( GameMode::showsGraphics() )
    5656        {
    5757            try
     
    7575        }
    7676
    77         if (Core::isMaster())
     77        if (GameMode::isMaster())
    7878        {
    7979            Vector3 velocity(rnd(-1, 1), rnd(-1, 1), rnd(-1, 1));
     
    132132            this->smoke_->setEnabled(false);
    133133
    134         if (Core::isMaster())
     134        if (GameMode::isMaster())
    135135        {
    136136            this->bStop_ = true;
     
    148148        static const unsigned int CHANGES_PER_SECOND = 5;
    149149
    150         if (Core::isMaster() && rnd() < dt*CHANGES_PER_SECOND)
     150        if (GameMode::isMaster() && rnd() < dt*CHANGES_PER_SECOND)
    151151        {
    152152            float length = this->getVelocity().length();
  • code/branches/gui/src/orxonox/objects/worldentities/Light.cc

    r2662 r2848  
    3737#include "util/String.h"
    3838#include "util/Exception.h"
    39 #include "core/Core.h"
     39#include "core/GameMode.h"
    4040#include "core/CoreIncludes.h"
    4141#include "core/XMLPort.h"
     
    5757        this->spotlightRange_ = Vector3(40.0f, 30.0f, 1.0f);
    5858
    59         if (Core::showsGraphics())
     59        if (GameMode::showsGraphics())
    6060        {
    6161            if (!this->getScene())
  • code/branches/gui/src/orxonox/objects/worldentities/Model.cc

    r2799 r2848  
    3131#include <OgreEntity.h>
    3232#include "Model.h"
    33 #include "core/Core.h"
     33#include "core/GameMode.h"
    3434#include "core/CoreIncludes.h"
    3535#include "core/XMLPort.h"
     
    7171    void Model::changedMesh()
    7272    {
    73         if (Core::showsGraphics())
     73        if (GameMode::showsGraphics())
    7474        {
    7575            if (this->mesh_.getEntity())
  • code/branches/gui/src/orxonox/objects/worldentities/MovableEntity.cc

    r2662 r2848  
    3434#include "core/XMLPort.h"
    3535#include "core/Executor.h"
    36 #include "core/Core.h"
     36#include "core/GameMode.h"
    3737
    3838namespace orxonox
     
    8989    void MovableEntity::resynchronize()
    9090    {
    91         if (Core::isMaster() && !this->continuousResynchroTimer_)
     91        if (GameMode::isMaster() && !this->continuousResynchroTimer_)
    9292        {
    9393            // Resynchronise every few seconds because we only work with velocities (no positions)
  • code/branches/gui/src/orxonox/objects/worldentities/ParticleEmitter.cc

    r2799 r2848  
    3939#include "tools/ParticleInterface.h"
    4040#include "util/Exception.h"
    41 #include "core/Core.h"
     41#include "core/GameMode.h"
    4242#include "core/CoreIncludes.h"
    4343#include "core/XMLPort.h"
     
    5252        RegisterObject(ParticleEmitter);
    5353
    54         if (Core::showsGraphics() && (!this->getScene() || !this->getScene()->getSceneManager()))
     54        if (GameMode::showsGraphics() && (!this->getScene() || !this->getScene()->getSceneManager()))
    5555            ThrowException(AbortLoading, "Can't create ParticleEmitter, no scene or no scene manager given.");
    5656
     
    108108        }
    109109
    110         if (Core::showsGraphics() && this->getScene() && this->getScene()->getSceneManager())
     110        if (GameMode::showsGraphics() && this->getScene() && this->getScene()->getSceneManager())
    111111        {
    112112            try
  • code/branches/gui/src/orxonox/objects/worldentities/pawns/Pawn.cc

    r2782 r2848  
    3030#include "Pawn.h"
    3131
    32 #include "core/Core.h"
     32#include "core/GameMode.h"
    3333#include "core/CoreIncludes.h"
    3434#include "core/XMLPort.h"
     
    6363        this->getPickUp().setPlayer(this);
    6464
    65         if (Core::isMaster())
     65        if (GameMode::isMaster())
    6666        {
    6767            this->weaponSystem_ = new WeaponSystem(this);
     
    187187            this->getPlayer()->stopControl(this);
    188188
    189         if (Core::isMaster())
     189        if (GameMode::isMaster())
    190190            this->deatheffect();
    191191    }
     
    234234    {
    235235        this->setHealth(this->initialHealth_);
    236         if (Core::isMaster())
     236        if (GameMode::isMaster())
    237237            this->spawneffect();
    238238    }
  • code/branches/gui/src/orxonox/objects/worldentities/pawns/Spectator.cc

    r2662 r2848  
    3434#include "core/CoreIncludes.h"
    3535#include "core/ConfigValueIncludes.h"
    36 #include "core/Core.h"
     36#include "core/GameMode.h"
    3737#include "objects/worldentities/Model.h"
    3838#include "objects/Scene.h"
     
    6363        this->setDestroyWhenPlayerLeft(true);
    6464
    65         if (Core::showsGraphics())
     65        if (GameMode::showsGraphics())
    6666        {
    6767            this->greetingFlare_ = new BillboardSet();
     
    206206        this->bGreeting_ = !this->bGreeting_;
    207207
    208         if (Core::isMaster())
     208        if (GameMode::isMaster())
    209209        {
    210210            this->bGreetingFlareVisible_ = this->bGreeting_;
  • code/branches/gui/src/orxonox/objects/worldentities/triggers/Trigger.cc

    r2710 r2848  
    3636#include "core/ConsoleCommand.h"
    3737#include "core/XMLPort.h"
    38 #include "core/Core.h"
     38#include "core/GameMode.h"
    3939#include "objects/Scene.h"
    4040
     
    6767//    this->bUpdating_ = false;
    6868
    69     if (this->getScene() && Core::showsGraphics())
     69    if (this->getScene() && GameMode::showsGraphics())
    7070    {
    7171      this->debugBillboard_.setBillboardSet(this->getScene()->getSceneManager(), "Examples/Flare", ColourValue(1.0, 0.0, 0.0), 1);
  • code/branches/gui/src/orxonox/overlays/OrxonoxOverlay.cc

    r2801 r2848  
    4444#include "util/Exception.h"
    4545#include "util/String.h"
    46 #include "core/Core.h"
     46#include "core/GameMode.h"
    4747#include "core/CoreIncludes.h"
    4848#include "core/XMLPort.h"
     
    6767        this->group_ = 0;
    6868
    69         if (!Core::showsGraphics())
     69        if (!GameMode::showsGraphics())
    7070            ThrowException(NoGraphics, "Can't create OrxonoxOverlay, graphics engine not initialized");
    7171
  • code/branches/gui/src/orxonox/tools/BillboardSet.cc

    r2662 r2848  
    3737#include <OgreBillboard.h>
    3838
    39 #include "core/Core.h"
     39#include "core/GameMode.h"
    4040#include "util/Convert.h"
    4141#include "util/String.h"
     
    7272        try
    7373        {
    74             if (Core::showsGraphics())
     74            if (GameMode::showsGraphics())
    7575            {
    7676                this->billboardSet_ = scenemanager->createBillboardSet("Billboard" + convertToString(BillboardSet::billboardSetCounter_s++), count);
     
    9595        try
    9696        {
    97             if (Core::showsGraphics())
     97            if (GameMode::showsGraphics())
    9898            {
    9999                this->billboardSet_ = scenemanager->createBillboardSet("Billboard" + convertToString(BillboardSet::billboardSetCounter_s++), count);
  • code/branches/gui/src/orxonox/tools/Mesh.cc

    r2662 r2848  
    3535#include <cassert>
    3636
    37 #include "core/Core.h"
     37#include "core/GameMode.h"
    3838#include "util/Convert.h"
    3939#include "util/String.h"
     
    6464            this->scenemanager_->destroyEntity(this->entity_);
    6565
    66         if (Core::showsGraphics())
     66        if (GameMode::showsGraphics())
    6767        {
    6868            try
  • code/branches/gui/src/orxonox/tools/ParticleInterface.cc

    r2801 r2848  
    4141
    4242#include "GraphicsManager.h"
    43 #include "core/Core.h"
     43#include "core/GameMode.h"
    4444#include "core/CoreIncludes.h"
    4545#include "util/Convert.h"
     
    6464        this->speedFactor_ = 1.0f;
    6565
    66         if (Core::showsGraphics())
     66        if (GameMode::showsGraphics())
    6767        {
    6868            try
     
    178178    {
    179179        this->detaillevel_ = level;
    180         if (Core::showsGraphics())
     180        if (GameMode::showsGraphics())
    181181            this->detailLevelChanged(GraphicsManager::getInstance().getDetailLevelParticle());
    182182    }
  • code/branches/gui/src/orxonox/tools/Shader.cc

    r2801 r2848  
    3636#include <OgrePlugin.h>
    3737
    38 #include "core/Core.h"
     38#include "core/GameMode.h"
    3939#include "core/CoreIncludes.h"
    4040#include "core/Executor.h"
     
    5959        this->compositorInstance_ = 0;
    6060        this->bVisible_ = true;
    61         this->bLoadCompositor_ = Core::showsGraphics();
     61        this->bLoadCompositor_ = GameMode::showsGraphics();
    6262        this->bViewportInitialized_ = false;
    6363        this->compositor_ = "";
     
    246246    Shader::ParameterPointer* Shader::getParameterPointer(const std::string& material, size_t technique, size_t pass, const std::string& parameter)
    247247    {
    248         if (!Core::showsGraphics() || !Shader::bLoadedCgPlugin_s)
     248        if (!GameMode::showsGraphics() || !Shader::bLoadedCgPlugin_s)
    249249            return 0;
    250250
Note: See TracChangeset for help on using the changeset viewer.