GunChleoc
Joined: 2013-10-07, 14:56
Posts: 3324
One Elder of Players
Location: RenderedRect
|
Posted at: 2016-05-13, 15:25
Tibor wrote:
GunChleoc wrote:
set_paused is also used by the save handler, so the same will stop running while being saved, and then return to its former speed, all without changing the game speed display.
OK, but if there is specific state "paused", the function is_paused() should not return paused if actual status is 'not paused but speed set to 0'
Good point - maybe rename the function to is_paused_or_zero_speed() , and still do both checks in there?
Busy indexing nil values
Top
Quote
|
|
|
Tibor
Topic Opener
Joined: 2009-03-23, 22:24
Posts: 1377
One Elder of Players
Location: Slovakia
|
Posted at: 2016-05-13, 18:48
GunChleoc wrote:
Tibor wrote:
GunChleoc wrote:
set_paused is also used by the save handler, so the same will stop running while being saved, and then return to its former speed, all without changing the game speed display.
OK, but if there is specific state "paused", the function is_paused() should not return paused if actual status is 'not paused but speed set to 0'
Good point - maybe rename the function to is_paused_or_zero_speed() , and still do both checks in there?
I am not sure, that getting rid of is_paused() is possible and so we would need to add such function as you propose. But I still think my approach is fine:
http://bazaar.launchpad.net/~widelands-dev/widelands/bug-1566441_Saving_game/view/head:/src/logic/save_handler.cc#L148
Top
Quote
|
|
|
MiroslavR
Joined: 2010-10-16, 16:56
Posts: 35
Pry about Widelands
Location: Slovakia
|
Posted at: 2016-05-13, 19:32
Hmm, thinking about it from another perspective I can see why is_paused() could be considered a getter for the "paused" state. Actually my solution changes the behavior of GameController::toggle_paused() slightly.
That said, I think having both is_paused() and is_paused_or_zero_speed() (defining it in the GameController base class would be enough) is a good compromise and should help prevent developers from choosing the wrong function in the future.
Top
Quote
|
|
|
Tibor
Topic Opener
Joined: 2009-03-23, 22:24
Posts: 1377
One Elder of Players
Location: Slovakia
|
Posted at: 2016-05-13, 20:44
OK, is_paused_or_zero_speed added (in launchpad already). But it needed quite a lot of edits.
Top
Quote
|
|
|
MiroslavR
Joined: 2010-10-16, 16:56
Posts: 35
Pry about Widelands
Location: Slovakia
|
Posted at: 2016-05-13, 20:52
MiroslavR wrote:
(defining it in the GameController base class would be enough)
As I said...
bool GameController::is_paused_or_zero_speed() {
return is_paused() || real_speed() == 0;
}
Should be enough? No need to modify the deriving classes?
Edited: 2016-05-13, 20:54
Top
Quote
|
|
|
GunChleoc
Joined: 2013-10-07, 14:56
Posts: 3324
One Elder of Players
Location: RenderedRect
|
Posted at: 2016-05-14, 07:41
Yep, in the top class should be OK.
Busy indexing nil values
Top
Quote
|
|
|
Tibor
Topic Opener
Joined: 2009-03-23, 22:24
Posts: 1377
One Elder of Players
Location: Slovakia
|
Posted at: 2016-05-14, 19:13
Oh, I did not get what you meant, I overlooked that 'GameController::'.... I reworked it...
Top
Quote
|