X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2FMoof%2FEngine.cc;h=ccfaf81e6d77b0b0b195f4c279a0d183563ac323;hp=de7c0cba94356afdc190110e97afcef3121cdc73;hb=7f3984f3f9524f5b6813e01ceb2fe576dadff94e;hpb=d11d8c63ab52c7f6eca2815e47cd6401e72f2c8c diff --git a/src/Moof/Engine.cc b/src/Moof/Engine.cc index de7c0cb..ccfaf81 100644 --- a/src/Moof/Engine.cc +++ b/src/Moof/Engine.cc @@ -27,7 +27,8 @@ *******************************************************************************/ #include -#include // exit +#include // exit, srand +#include // time #include #include @@ -41,7 +42,6 @@ #include "Exception.hh" #include "Log.hh" #include "Math.hh" -#include "Random.hh" #include "Settings.hh" #include "Timer.hh" @@ -69,6 +69,13 @@ public: const char* error = SDL_GetError(); throw Exception(ErrorCode::SDL_INIT, error); } + else + { + char vdName[128]; + SDL_VideoDriverName(vdName, sizeof(vdName)); + logDebug << "initialized SDL; using video driver `" + << vdName << "'" << std::endl; + } if (FE_Init() != 0) { @@ -81,13 +88,15 @@ public: if (!mAlDevice || !mAlContext) { const char* error = alcGetString(mAlDevice,alcGetError(mAlDevice)); - logError("error while creating audio context: %s", error); + logError << "error while creating audio context: " + << error << std::endl; } else { alcMakeContextCurrent(mAlContext); - logDebug("opened sound device \"%s\"", - alcGetString(mAlDevice, ALC_DEFAULT_DEVICE_SPECIFIER)); + logDebug << "opened sound device `" + << alcGetString(mAlDevice, ALC_DEFAULT_DEVICE_SPECIFIER) + << "'" << std::endl; } // now load the settings the engine needs @@ -95,8 +104,8 @@ public: Settings& settings = Settings::getInstance(); unsigned randomSeed; - if (settings.get("rngseed", randomSeed)) setSeed(randomSeed); - else setSeed(); + if (settings.get("rngseed", randomSeed)) srand(randomSeed); + else srand(time(0)); Scalar timestep = 80.0; settings.get("timestep", timestep); @@ -190,7 +199,7 @@ public: if (mPrintFps) { - logInfo("%d fps", mFps); + logInfo << mFps << " fps" << std::endl; } } @@ -210,6 +219,8 @@ public: Timer::getNextFire()), Timer::ACTUAL); } while (!mStack.empty()); + + mDispatch.dispatch("engine.stopping"); } void dispatchEvents() @@ -271,7 +282,8 @@ public: { ASSERT(layer && "cannot push null layer"); mStack.push_front(layer); - logDebug("stack: %d [pushed %X]", mStack.size(), layer.get()); + logDebug << "stack: " << mStack.size() + << " [pushed " << layer.get() << "]" << std::endl; layer->pushed(mInterface); } @@ -282,7 +294,8 @@ public: LayerP layer = mStack.front(); mStack.pop_front(); - logDebug("stack: %d [popped %X]", mStack.size(), layer.get()); + logDebug << "stack: " << mStack.size() + << " [popped " << layer.get() << "]" << std::endl; layer->popped(mInterface); if (fixIt) mStackIt = --mStack.begin(); @@ -311,7 +324,8 @@ public: for (it = layers.begin(); it != layers.end(); ++it) { (*it)->popped(mInterface); - logDebug("stack: %d [popped %X]", mStack.size(), (*it).get()); + logDebug << "stack: " << mStack.size() + << " [popped " << (*it).get() << "]" << std::endl; } if (fixIt) mStackIt = --mStack.begin(); @@ -335,7 +349,8 @@ public: { if (mMaxFps < mTimestep) { - logWarning("capping maximum fps to timestep (%f)", mTimestep); + logWarning << "capping maximum fps to timestep (" + << mTimestep << ")" << std::endl; mMaxFps = mTimestep; } }