diff options
| author | urukgit | 2013-11-05 21:12:50 +0100 | 
|---|---|---|
| committer | urukgit | 2013-11-05 21:12:50 +0100 | 
| commit | b041e322a4a9533be3ee0a35d8b4e51c47f17eda (patch) | |
| tree | 81f9662d9e032e8202aeb9587a9068e170aab558 | |
| parent | e9c5265d45dd83913fb4d65b8980fbf504252ff7 (diff) | |
| download | scummvm-rg350-b041e322a4a9533be3ee0a35d8b4e51c47f17eda.tar.gz scummvm-rg350-b041e322a4a9533be3ee0a35d8b4e51c47f17eda.tar.bz2 scummvm-rg350-b041e322a4a9533be3ee0a35d8b4e51c47f17eda.zip | |
AVALANCHE: Repair display of playtime.
| -rw-r--r-- | engines/avalanche/avalanche.cpp | 13 | ||||
| -rw-r--r-- | engines/avalanche/avalanche.h | 12 | ||||
| -rw-r--r-- | engines/avalanche/avalot.cpp | 9 | ||||
| -rw-r--r-- | engines/avalanche/background.cpp | 46 | ||||
| -rw-r--r-- | engines/avalanche/parser.cpp | 8 | ||||
| -rw-r--r-- | engines/avalanche/timer.cpp | 8 | 
6 files changed, 57 insertions, 39 deletions
| diff --git a/engines/avalanche/avalanche.cpp b/engines/avalanche/avalanche.cpp index b45f17886d..53a75831d7 100644 --- a/engines/avalanche/avalanche.cpp +++ b/engines/avalanche/avalanche.cpp @@ -94,8 +94,6 @@ void AvalancheEngine::initVariables() {  		_also[i][1] = nullptr;  	} -	_totalTime = 0; -  	memset(_fxPal, 0, 16 * 16 * 3);  	for (int i = 0; i < 15; i++) { @@ -126,7 +124,7 @@ void AvalancheEngine::initVariables() {  	_him = kPeoplePardon;  	_her = kPeoplePardon;  	_it = Parser::kPardon; -	_roomTime = 0; +	_roomCycles = 0;  	_doingSpriteRun = false;  	_isLoaded = false;  	_soundFx = true; @@ -359,6 +357,8 @@ bool AvalancheEngine::saveGame(const int16 slot, const Common::String &desc) {  	f->writeSint16LE(t.tm_mday);  	f->writeSint16LE(t.tm_mon);  	f->writeSint16LE(t.tm_year); +     +    _totalTime += getTimeInSeconds() - _startTime;  	Common::Serializer sz(NULL, f);  	synchronize(sz); @@ -422,6 +422,7 @@ bool AvalancheEngine::loadGame(const int16 slot) {  	delete f;  	_isLoaded = true; +    _ableToAddTimer = false;  	_seeScroll = true;  // This prevents display of the new sprites before the new picture is loaded.  	if (_holdTheDawn) { @@ -478,6 +479,12 @@ Common::String AvalancheEngine::expandDate(int d, int m, int y) {  	return day + ' ' + month + ' ' + intToStr(y + 1900);  } +     +uint32 AvalancheEngine::getTimeInSeconds() { +    TimeDate time; +    _system->getTimeAndDate(time); +    return time.tm_hour * 3600 + time.tm_min * 60 + time.tm_sec; +}  void AvalancheEngine::updateEvents() {  	Common::Event event; diff --git a/engines/avalanche/avalanche.h b/engines/avalanche/avalanche.h index b6e168f830..9c0fb3475b 100644 --- a/engines/avalanche/avalanche.h +++ b/engines/avalanche/avalanche.h @@ -111,6 +111,7 @@ public:  	Common::Error loadGameState(int slot);  	bool loadGame(const int16 slot);  	Common::String expandDate(int d, int m, int y); +    uint32 getTimeInSeconds();  	void updateEvents();  	bool getEvent(Common::Event &event); // A wrapper around _eventMan->pollEvent(), so we can use it in Scrolls::normscroll() for example. @@ -210,7 +211,8 @@ public:  	bool _takenPen; // Have you taken the pen (in Cardiff?)  	bool _arrowInTheDoor;  // Did the arrow hit the wall?  	Common::String _favoriteDrink, _favoriteSong, _worstPlaceOnEarth, _spareEvening; // Personalisation str's -	uint32 _totalTime; // Your total time playing this game, in ticks. +    uint32 _startTime; // When did you start playing this session? +    uint32 _totalTime; // Your total time playing this game, in seconds. Updated only at saving and loading.  	byte _jumpStatus; // Fixes how high you're jumping.  	bool _mushroomGrowing; // Is the mushroom growing in 42?  	bool _crapulusWillTell; // Will Crapulus tell you about Spludwick being away? @@ -257,12 +259,16 @@ public:  	byte _subjectNum; // The same thing.  	People _him, _her;  	byte _it; -	uint32 _roomTime; // Set to 0 when you enter a room, added to in every loop. +	uint32 _roomCycles; // Set to 0 when you enter a room, added to in every loop. Cycles since you've been in this room.  	bool _doingSpriteRun; // Only set to True if we're doing a sprite_run at this moment. This stops the trippancy system from moving any of the sprites. -	bool _isLoaded; // Is it a loaded gamestate?  	bool _soundFx; +    // These two have very similar purpose, but it's crucial not to modify _isLoaded later than the actual loading +    // or at the begginning of the game, and _ablteToAddTimer must be modified in addTimer(). +    bool _isLoaded; // Is it a loaded gamestate? +    bool _ableToAddTimer; +      	void callVerb(VerbCode id);  	void loadRoom(byte num);  	void thinkAbout(byte object, bool type); // Hey!!! Get it and put it!!! diff --git a/engines/avalanche/avalot.cpp b/engines/avalanche/avalot.cpp index 36ce16d09c..2a11a92493 100644 --- a/engines/avalanche/avalot.cpp +++ b/engines/avalanche/avalot.cpp @@ -295,7 +295,6 @@ void AvalancheEngine::setup() {  		loadGame(loadSlot);  	} else { -		_isLoaded = false; // Set to true in _vm->loadGame().  		newGame();  		_soundFx = !_soundFx; @@ -639,8 +638,7 @@ void AvalancheEngine::enterRoom(Room roomId, byte ped) {  	if (_geidaFollows)  		_whereIs[kPeopleGeida - 150] = roomId; -	_roomTime = 0; - +	_roomCycles = 0;  	if ((_lastRoom == kRoomMap) && (_lastRoomNotMap != _room))  		enterNewTown(); @@ -1006,7 +1004,6 @@ void AvalancheEngine::enterRoom(Room roomId, byte ped) {  	}  	_seeScroll = false; // Now it can work again! -	_isLoaded = false;  }  void AvalancheEngine::thinkAbout(byte object, bool type) { @@ -1482,6 +1479,7 @@ void AvalancheEngine::resetVariables() {  	_takenMushroom = false;  	_givenPenToAyles = false;  	_askedDogfoodAboutNim = false; +    _startTime = getTimeInSeconds();  	_parser->resetVariables();  	_animation->resetVariables(); @@ -1531,6 +1529,9 @@ void AvalancheEngine::newGame() {  	_userMovesAvvy = false;  	_doingSpriteRun = false;  	_avvyInBed = true; +     +    _ableToAddTimer = true; // Set to false in _vm->loadGame(). +    _isLoaded = false;  	enterRoom(kRoomYours, 1);  	avvy->_visible = false; diff --git a/engines/avalanche/background.cpp b/engines/avalanche/background.cpp index 4d71550213..523b7a6826 100644 --- a/engines/avalanche/background.cpp +++ b/engines/avalanche/background.cpp @@ -53,23 +53,23 @@ void Background::update() {  	switch (_vm->_room) {  	case kRoomOutsideArgentPub: -		if ((_vm->_roomTime % 12) == 0) -			draw(-1, -1, (_vm->_roomTime / 12) % 4); +		if ((_vm->_roomCycles % 12) == 0) +			draw(-1, -1, (_vm->_roomCycles / 12) % 4);  		break;  	case kRoomBrummieRoad: -		if ((_vm->_roomTime % 2) == 0) -			draw(-1, -1, (_vm->_roomTime / 2) % 4); +		if ((_vm->_roomCycles % 2) == 0) +			draw(-1, -1, (_vm->_roomCycles / 2) % 4);  		break;  	case kRoomBridge: -		if ((_vm->_roomTime % 2) == 0) -			draw(-1, -1, 3 + (_vm->_roomTime / 2) % 4); +		if ((_vm->_roomCycles % 2) == 0) +			draw(-1, -1, 3 + (_vm->_roomCycles / 2) % 4);  		break;  	case kRoomYours: -		if ((!_vm->_avvyIsAwake) && ((_vm->_roomTime % 4) == 0)) -			draw(-1, -1, (_vm->_roomTime / 12) % 2); +		if ((!_vm->_avvyIsAwake) && ((_vm->_roomCycles % 4) == 0)) +			draw(-1, -1, (_vm->_roomCycles / 12) % 2);  		break;  	case kRoomArgentPub: -		if (((_vm->_roomTime % 7) == 1) && (_vm->_malagauche != 177)) { +		if (((_vm->_roomCycles % 7) == 1) && (_vm->_malagauche != 177)) {  			// Malagauche cycle.  			_vm->_malagauche++;  			switch (_vm->_malagauche) { @@ -93,7 +93,7 @@ void Background::update() {  			}  		} -		switch (_vm->_roomTime % 200) { +		switch (_vm->_roomCycles % 200) {  		case 179:  		case 197:  			draw(-1, -1, 4); // Dogfood's drinking cycle. @@ -109,7 +109,7 @@ void Background::update() {  			_vm->_npcFacing = 177; // Impossible value for this.  			break;  		default: -			if (_vm->_roomTime % 200 <= 178) { // Normally. +			if (_vm->_roomCycles % 200 <= 178) { // Normally.  				byte direction = 1;  				uint16 angle = _vm->bearing(1);  				if (((angle >= 1) && (angle <= 90)) || ((angle >= 358) && (angle <= 360))) @@ -127,8 +127,8 @@ void Background::update() {  		}  		break;  	case kRoomWestHall: -		if ((_vm->_roomTime % 3) == 0) { -			switch ((_vm->_roomTime / 3) % 6) { +		if ((_vm->_roomCycles % 3) == 0) { +			switch ((_vm->_roomCycles / 3) % 6) {  			case 4:  				draw(-1, -1, 0);  				break; @@ -148,7 +148,7 @@ void Background::update() {  		if (!(_vm->_lustieIsAsleep)) {  			byte direction = 0;  			uint16 angle = _vm->bearing(1); -			if ((_vm->_roomTime % 45) > 42) +			if ((_vm->_roomCycles % 45) > 42)  				direction = 4; // du Lustie blinks.  			// Bearing of Avvy from du Lustie.  			else if ((angle <= 45) || ((angle >= 315) && (angle <= 360))) @@ -165,8 +165,8 @@ void Background::update() {  		}  		break;  	case kRoomAylesOffice: -		if ((!_vm->_aylesIsAwake) && (_vm->_roomTime % 14 == 0)) { -			switch ((_vm->_roomTime / 14) % 2) { +		if ((!_vm->_aylesIsAwake) && (_vm->_roomCycles % 14 == 0)) { +			switch ((_vm->_roomCycles / 14) % 2) {  			case 0:  				draw(-1, -1, 0);  // Frame 2: EGA.  				break; @@ -178,7 +178,7 @@ void Background::update() {  		break;  	case kRoomRobins:  		if (_vm->_tiedUp) { -			switch (_vm->_roomTime % 54) { +			switch (_vm->_roomCycles % 54) {  			case 20:  				draw(-1, -1, 3); // Frame 4: Avalot blinks.  				break; @@ -199,7 +199,7 @@ void Background::update() {  		else if ((angle >= 181) && (angle <= 314))  			direction = 8; // Right. -		if ((_vm->_roomTime % 60) > 57) +		if ((_vm->_roomCycles % 60) > 57)  			direction--; // Blinks.  		if (direction != _vm->_npcFacing) { // Port. @@ -207,7 +207,7 @@ void Background::update() {  			_vm->_npcFacing = direction;  		} -		switch (_vm->_roomTime % 50) { +		switch (_vm->_roomCycles % 50) {  		case 45 :  			draw(-1, -1, 8); // Spurge blinks.  			break; @@ -218,8 +218,8 @@ void Background::update() {  		break;  	  }  	case kRoomDucks: { -		if ((_vm->_roomTime % 3) == 0) // The fire flickers. -			draw(-1, -1, (_vm->_roomTime / 3) % 3); +		if ((_vm->_roomCycles % 3) == 0) // The fire flickers. +			draw(-1, -1, (_vm->_roomCycles / 3) % 3);  		// Bearing of Avvy from Duck.  		byte direction = 0; @@ -231,7 +231,7 @@ void Background::update() {  		else if ((angle >= 181) && (angle <= 314))  			direction = 8; // Right. -		if ((_vm->_roomTime % 45) > 42) +		if ((_vm->_roomCycles % 45) > 42)  			direction++; // Duck blinks.  		if (direction != _vm->_npcFacing) { // Duck. @@ -246,7 +246,7 @@ void Background::update() {  	if ((_vm->_bellsAreRinging) && (_vm->getFlag('B'))) {  		// They're ringing the bells. -		switch (_vm->_roomTime % 4) { +		switch (_vm->_roomCycles % 4) {  		case 1:  			if (_nextBell < 5)  				_nextBell = 12; diff --git a/engines/avalanche/parser.cpp b/engines/avalanche/parser.cpp index 9b6b841c8a..d71e08f773 100644 --- a/engines/avalanche/parser.cpp +++ b/engines/avalanche/parser.cpp @@ -603,8 +603,12 @@ Common::String Parser::rank() {  Common::String Parser::totalTime() {  	uint16 h, m, s; -	h = (uint16)(_vm->_totalTime / 65535); -	s = (uint16)(_vm->_totalTime % 65535); +	uint32 curTime = _vm->getTimeInSeconds() - _vm->_startTime; +    if (_vm->_isLoaded) +        curTime += _vm->_totalTime; +     +    h = (uint16)(curTime / 3600); +    s = (uint16)(curTime  % 3600);  	m = s / 60;  	s = s % 60; diff --git a/engines/avalanche/timer.cpp b/engines/avalanche/timer.cpp index 4e90c7fe48..a62a263695 100644 --- a/engines/avalanche/timer.cpp +++ b/engines/avalanche/timer.cpp @@ -48,7 +48,7 @@ Timer::Timer(AvalancheEngine *vm) {   * @remarks	Originally called 'set_up_timer'   */  void Timer::addTimer(int32 duration, byte action, byte reason) { -	if ((_vm->_isLoaded == false) || (_timerLost == true)) { +	if ((_vm->_ableToAddTimer == false) || (_timerLost == true)) {  		byte i = 0;  		while ((i < 7) && (_times[i]._timeLeft != 0))  			i++; @@ -61,7 +61,7 @@ void Timer::addTimer(int32 duration, byte action, byte reason) {  		_times[i]._action = action;  		_times[i]._reason = reason;  	} else { -		_vm->_isLoaded = false; +		_vm->_ableToAddTimer = false;  		return;  	}  } @@ -208,8 +208,8 @@ void Timer::updateTimer() {  			}  		}  	} -	_vm->_roomTime++; // Cycles since you've been in this room. -	_vm->_totalTime++; // Total amount of time for this game. +     +	_vm->_roomCycles++; // Cycles since you've been in this room.  }  void Timer::loseTimer(byte which) { | 
