Ejemplo n.º 1
0
bool GlobalTimer::Update()
{
	Map *map;
	Game *game;
	GameControl* gc;
	unsigned long thisTime;
	unsigned long advance;

	gc = core->GetGameControl();
	if (gc)
		gc->UpdateScrolling();

	UpdateAnimations();

	thisTime = GetTickCount();

	if (!startTime) {
		startTime = thisTime;
		return false;
	}

	advance = thisTime - startTime;
	if ( advance < interval) {
		return false;
	}
	ieDword count = advance/interval;
	DoStep(count);
	DoFadeStep(count);
	if (!gc) {
		goto end;
	}
	game = core->GetGame();
	if (!game) {
		goto end;
	}
	map = game->GetCurrentArea();
	if (!map) {
		goto end;
	}
	//do spell effects expire in dialogs?
	//if yes, then we should remove this condition
	if (!(gc->GetDialogueFlags()&DF_IN_DIALOG) ) {
		map->UpdateFog();
		map->UpdateEffects();
		if (thisTime) {
			//this measures in-world time (affected by effects, actions, etc)
			game->AdvanceTime(1);
		}
	}
	//this measures time spent in the game (including pauses)
	if (thisTime) {
		game->RealTime++;
	}
end:
	startTime = thisTime;
	return true;
}