GRIM: Make perSecond() return 0 for the first two loops. Fixes #40

This commit is contained in:
Giulio Camuffo 2011-04-26 21:55:55 +02:00
parent 1e56e01913
commit 3497817f31
2 changed files with 23 additions and 1 deletions

View file

@ -885,6 +885,8 @@ void GrimEngine::mainLoop() {
_savegameSaveRequest = false;
_savegameFileName = NULL;
_refreshShadowMask = false;
_discardLoop = true;
int counter = 0;
for (;;) {
uint32 startTime = g_system->getMillis();
@ -946,6 +948,18 @@ void GrimEngine::mainLoop() {
g_imuseState = -1;
}
// This is a trick to make the first two loops pass by without having
// perSecond return enormous numbers, since the _frameTime for them is big,
// few seconds. This is important for the set "ly", since unicycle_man
// uses walkForward to move as soon as the set starts and without this trick
// it would result in him making big steps and jumping over his destination point.
if (_discardLoop) {
if (counter == 1)
_discardLoop = false;
++counter;
}
uint32 endTime = g_system->getMillis();
if (startTime > endTime)
continue;
@ -1439,6 +1453,13 @@ bool GrimEngine::getControlState(int num) {
return _controlsState[num];
}
float GrimEngine::perSecond(float rate) const {
if (_discardLoop)
return 0;
return rate * _frameTime / 1000;
}
void GrimEngine::registerTextObject(TextObject *t) {
_textObjects[t->_id] = t;
}

View file

@ -109,7 +109,7 @@ public:
// perSecond should allow rates of zero, some actors will accelerate
// up to their normal speed (such as the bone wagon) so handling
// a walking rate of zero should happen in the default actor creation
float perSecond(float rate) const { return rate * _frameTime / 1000; }
float perSecond(float rate) const;
int getTextSpeed() { return _textSpeed; }
void setTextSpeed(int speed);
@ -276,6 +276,7 @@ private:
unsigned _speedLimitMs;
bool _showFps;
bool _softRenderer;
bool _discardLoop;
bool *_controlsEnabled;
bool *_controlsState;