Re: [Widelands-dev] [Merge] lp:~widelands-dev/widelands/map_object_info into lp:widelands
Review: Resubmit The output path is now defined on the command line when calling the executable. If the new changes are OK, this can go in now. -- https://code.launchpad.net/~widelands-dev/widelands/map_object_info/+merge/287409 Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/map_object_info. ___ Mailing list: https://launchpad.net/~widelands-dev Post to : widelands-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~widelands-dev More help : https://help.launchpad.net/ListHelp
[Widelands-dev] [Merge] lp:~widelands-dev/widelands/map_object_info into lp:widelands
GunChleoc has proposed merging lp:~widelands-dev/widelands/map_object_info into lp:widelands. Commit message: Created a new executable that will generate JSON files for updating the encyclopedia on the website. Requested reviews: GunChleoc (gunchleoc) kaputtnik (franku): testing Related bugs: Bug #350465 in widelands: "online_help returns false information" https://bugs.launchpad.net/widelands/+bug/350465 Bug #1324015 in widelands: "Rework wares encyclopedia" https://bugs.launchpad.net/widelands/+bug/1324015 For more details, see: https://code.launchpad.net/~widelands-dev/widelands/map_object_info/+merge/287409 Created a new executable that will generate JSON files for updating the encyclopedia on the website. I recommend that we wait with merging this when we get close to the release candidate, because we now have extra linking time with each compile. Related website branch: https://code.launchpad.net/~widelands-dev/widelands-website/encyclopedia -- Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/map_object_info. === added directory 'data/tribes/scripting/mapobject_info' === added file 'data/tribes/scripting/mapobject_info/building_helptext.lua' --- data/tribes/scripting/mapobject_info/building_helptext.lua 1970-01-01 00:00:00 + +++ data/tribes/scripting/mapobject_info/building_helptext.lua 2016-05-14 07:36:19 + @@ -0,0 +1,9 @@ +-- This is used by the mapinfo standalone executable to get buildings' helptexts. +-- Note that this can't handle localization properly. + +return { + func = function(helptext_script) + include(helptext_script) + return building_helptext_purpose() + end +} === added file 'data/tribes/scripting/mapobject_info/ware_helptext.lua' --- data/tribes/scripting/mapobject_info/ware_helptext.lua 1970-01-01 00:00:00 + +++ data/tribes/scripting/mapobject_info/ware_helptext.lua 2016-05-14 07:36:19 + @@ -0,0 +1,9 @@ +-- This is used by the mapinfo standalone executable to get wares' helptexts. +-- Note that this can't handle localization properly. + +return { + func = function(tribename, helptext_script) + include(helptext_script) + return ware_helptext(tribename) + end +} === added file 'data/tribes/scripting/mapobject_info/worker_helptext.lua' --- data/tribes/scripting/mapobject_info/worker_helptext.lua 1970-01-01 00:00:00 + +++ data/tribes/scripting/mapobject_info/worker_helptext.lua 2016-05-14 07:36:19 + @@ -0,0 +1,9 @@ +-- This is used by the mapinfo standalone executable to get workers' helptexts. +-- Note that this can't handle localization properly. + +return { + func = function(helptext_script) + include(helptext_script) + return worker_helptext() + end +} === modified file 'debian/widelands.install' --- debian/widelands.install 2016-01-22 07:20:01 + +++ debian/widelands.install 2016-05-14 07:36:19 + @@ -1,5 +1,6 @@ usr/widelands usr/games usr/wl_map_info usr/games +usr/wl_mapobject_info usr/games usr/wl_render_richtext usr/games usr/share/applications usr/share/icons === modified file 'src/CMakeLists.txt' --- src/CMakeLists.txt 2016-02-06 11:11:24 + +++ src/CMakeLists.txt 2016-05-14 07:36:19 + @@ -82,6 +82,7 @@ add_subdirectory(third_party) add_subdirectory(ui_basic) add_subdirectory(ui_fsmenu) +add_subdirectory(website) add_subdirectory(wui) # TODO(unknown): Ideally widelands_ball_of_mud shouldn't exist, everything should be in a === modified file 'src/logic/CMakeLists.txt' --- src/logic/CMakeLists.txt 2016-03-19 15:49:51 + +++ src/logic/CMakeLists.txt 2016-05-14 07:36:19 + @@ -1,19 +1,3 @@ -wl_binary(wl_map_info - SRCS -map_info.cc - USES_SDL2 - DEPENDS -base_log -graphic -graphic_image_io -graphic_minimap_renderer -graphic_surface -io_fileread -io_filesystem -logic -map_io_map_loader -) - wl_library(logic_widelands_geometry SRCS widelands_geometry.cc === modified file 'src/logic/map_objects/immovable.cc' --- src/logic/map_objects/immovable.cc 2016-03-21 05:45:29 + +++ src/logic/map_objects/immovable.cc 2016-05-14 07:36:19 + @@ -58,9 +58,11 @@ namespace Widelands { -namespace { +BaseImmovable::BaseImmovable(const MapObjectDescr & mo_descr) : +MapObject(&mo_descr) +{} -BaseImmovable::Size string_to_size(const std::string& size) { +int32_t BaseImmovable::string_to_size(const std::string& size) { if (size == "none") return BaseImmovable::NONE; if (size == "small") @@ -72,13 +74,20 @@ throw GameDataError("Unknown size %s.", size.c_str()); } -} // namespace - - -BaseImmovable::BaseImmovable(const MapObjectDescr & mo_descr) : -MapObject(&mo_descr) -{} - +std::string BaseImmovable::size_to_string(int32_t size) { + switch (size) { + case BaseImmovable::NONE: + return "none"; + case BaseImmovable::SMALL: + return "small"; + case BaseImmovable::MEDIUM: + return "medium"; + case BaseImmovable::BIG: + return "big"; + default: + NEVER_HERE(); + }
Re: [Widelands-dev] [Merge] lp:~widelands-dev/widelands-website/encyclopedia into lp:widelands-website
The C++ code has been updated now to specify the output dir on the command line. I can't get the website code to run after my recent system upgrade though, so I don't know how to finish up this branch :( -- https://code.launchpad.net/~widelands-dev/widelands-website/encyclopedia/+merge/287410 Your team Widelands Developers is subscribed to branch lp:widelands-website. ___ Mailing list: https://launchpad.net/~widelands-dev Post to : widelands-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~widelands-dev More help : https://help.launchpad.net/ListHelp
[Widelands-dev] [Merge] lp:~widelands-dev/widelands/map_object_info into lp:widelands
Continuous integration builds have changed state: Travis build 797. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/113180179. Appveyor build 643. State: failed. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_map_object_info-643. -- https://code.launchpad.net/~widelands-dev/widelands/map_object_info/+merge/287409 Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/map_object_info. ___ Mailing list: https://launchpad.net/~widelands-dev Post to : widelands-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~widelands-dev More help : https://help.launchpad.net/ListHelp
[Widelands-dev] [Merge] lp:~widelands-dev/widelands/fix_tut1_destroy_quarries into lp:widelands
GunChleoc has proposed merging lp:~widelands-dev/widelands/fix_tut1_destroy_quarries into lp:widelands. Commit message: Trigger destroy_quarries_message in Tutorial 1 with 1 message. Requested reviews: Widelands Developers (widelands-dev) For more details, see: https://code.launchpad.net/~widelands-dev/widelands/fix_tut1_destroy_quarries/+merge/294699 In case the user deletes the first message before the second one comes in. Bug reported on the forum https://wl.widelands.org/forum/topic/1970/ -- Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/fix_tut1_destroy_quarries into lp:widelands. === modified file 'data/campaigns/tutorial01_basic_control.wmf/scripting/mission_thread.lua' --- data/campaigns/tutorial01_basic_control.wmf/scripting/mission_thread.lua 2015-11-04 16:48:56 + +++ data/campaigns/tutorial01_basic_control.wmf/scripting/mission_thread.lua 2016-05-14 07:55:41 + @@ -333,7 +333,7 @@ remove_all_rocks(first_quarry_field:region(6)) -- Wait for messages to arrive - while #plr.inbox < 2 do sleep(300) end + while #plr.inbox < 1 do sleep(300) end local o = message_box_objective(plr, destroy_quarries_message) ___ Mailing list: https://launchpad.net/~widelands-dev Post to : widelands-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~widelands-dev More help : https://help.launchpad.net/ListHelp
Re: [Widelands-dev] [Merge] lp:~widelands-dev/widelands/bug-1581647-compiler-warnings into lp:widelands
Review: Approve compiling Compiles fine again. Except the warnings regarding NEVER_HERE(): Warnung: throw will always call terminate() [-Wterminate] Seems to be ok then. -- https://code.launchpad.net/~widelands-dev/widelands/bug-1581647-compiler-warnings/+merge/294698 Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/bug-1581647-compiler-warnings. ___ Mailing list: https://launchpad.net/~widelands-dev Post to : widelands-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~widelands-dev More help : https://help.launchpad.net/ListHelp
[Widelands-dev] [Merge] lp:~widelands-dev/widelands/bug-1418154-collectors-teams into lp:widelands
GunChleoc has proposed merging lp:~widelands-dev/widelands/bug-1418154-collectors-teams into lp:widelands. Commit message: Collectors now reports team scores as well as player scores. Requested reviews: Widelands Developers (widelands-dev) Related bugs: Bug #1418154 in widelands: "Collectors in teams: points are shown for each single player" https://bugs.launchpad.net/widelands/+bug/1418154 For more details, see: https://code.launchpad.net/~widelands-dev/widelands/bug-1418154-collectors-teams/+merge/294702 -- Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/bug-1418154-collectors-teams into lp:widelands. === modified file 'data/scripting/win_conditions/collectors.lua' --- data/scripting/win_conditions/collectors.lua 2016-03-15 08:42:41 + +++ data/scripting/win_conditions/collectors.lua 2016-05-14 10:42:25 + @@ -31,13 +31,17 @@ -- set the objective with the game type for all players broadcast_objective("win_condition", wc_descname, wc_desc) - -- Simple flowing text. One Paragraph - local function p(s) - return "" .. s .. "" .. - " " + local plrs = wl.Game().players + local teams = {} + for idx,plr in ipairs(plrs) do + if (plr.team ~= 0) then + if (teams[plr.team] == nil) then +teams[plr.team] = {} + end + table.insert(teams[plr.team], plr) + end end - -- The list of wares that give points local point_table = { barbarians = { @@ -93,36 +97,42 @@ }, } - -- Calculate the momentary points for one player - local function _calc_points(plr) + -- Calculate the momentary points for a list of players + local function _calc_points(players) set_textdomain("win_conditions") - local bs = array_combine( - plr:get_buildings(plr.tribe_name .. "_headquarters"), plr:get_buildings(plr.tribe_name .. "_warehouse"), plr:get_buildings(plr.tribe_name .. "_port") - ) - - local points = 0 - local descr = { "" .. h2((_"Status for %s"):format(plr.name)) .. ""} - for idx, ware in ipairs(point_table[plr.tribe_name .. "_order"]) do - local value = point_table[plr.tribe_name][ware] - local count = 0 - for idx,b in ipairs(bs) do -count = count + b:get_wares(ware) - end - local lpoints = count * value - points = points + lpoints - - local warename = wl.Game():get_ware_description(ware).descname - -- TRANSLATORS: For example: 'gold (3 P) x 4 = 12 P', P meaning 'Points' - descr[#descr+1] = listitem_bullet(_"%1$s (%2$i P) x %3$i = %4$i P"):bformat( -warename, value, count, lpoints + local team_points = 0 + local descr = "" + + for idx, plr in ipairs(players) do + local bs = array_combine( +plr:get_buildings(plr.tribe_name .. "_headquarters"), plr:get_buildings(plr.tribe_name .. "_warehouse"), plr:get_buildings(plr.tribe_name .. "_port") ) + + descr = descr .. h2((_"Status for %s"):format(plr.name)) + local points = 0 + for idx, ware in ipairs(point_table[plr.tribe_name .. "_order"]) do +local value = point_table[plr.tribe_name][ware] +local count = 0 +for idx,b in ipairs(bs) do + count = count + b:get_wares(ware) +end +local lpoints = count * value +points = points + lpoints + +local warename = wl.Game():get_ware_description(ware).descname +-- TRANSLATORS: For example: 'gold (3 P) x 4 = 12 P', P meaning 'Points' +descr = descr .. listitem_bullet(_"%1$s (%2$i P) x %3$i = %4$i P"):bformat( + warename, value, count, lpoints +) + end + descr = descr .. "" .. h3(ngettext("Total: %i point", "Total: %i points", points)):format(points) + team_points = team_points + points end - descr[#descr+1] = "" .. h3(ngettext("Total: %i point", "Total: %i points", points)):format(points) - .. "" - return points, p(table.concat(descr, "\n")) + + return team_points, descr end - local plrs = wl.Game().players + -- Send all players the momentary game state local function _send_state(remaining_time, plrs) set_textdomain("win_conditions") @@ -144,12 +154,21 @@ end -- TRANSLATORS: Context: 'The game will end in 2 hours and 30 minutes.' local msg = p(_"The game will end in %s."):format(time) - msg = msg .. "\n\n" + -- Points for players without team for idx, plr in ipairs(plrs) do - local points, pstat = _calc_points(plr) - - msg = msg .. pstat + if (plr.team == 0) then +local points, pstat = _calc_points({plr}) +msg = msg .. " " .. pstat + end + end + -- Team points + for idx, team in ipairs(teams) do + local points, pstat =
Re: [Widelands-dev] [Merge] lp:~widelands-dev/widelands/bug-1581647-compiler-warnings into lp:widelands
Thanks! @bunnybot merge -- https://code.launchpad.net/~widelands-dev/widelands/bug-1581647-compiler-warnings/+merge/294698 Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/bug-1581647-compiler-warnings. ___ Mailing list: https://launchpad.net/~widelands-dev Post to : widelands-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~widelands-dev More help : https://help.launchpad.net/ListHelp
[Widelands-dev] [Merge] lp:~widelands-dev/widelands/bug-1581647-compiler-warnings into lp:widelands
The proposal to merge lp:~widelands-dev/widelands/bug-1581647-compiler-warnings into lp:widelands has been updated. Status: Needs review => Merged For more details, see: https://code.launchpad.net/~widelands-dev/widelands/bug-1581647-compiler-warnings/+merge/294698 -- Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/bug-1581647-compiler-warnings. ___ Mailing list: https://launchpad.net/~widelands-dev Post to : widelands-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~widelands-dev More help : https://help.launchpad.net/ListHelp
Re: [Widelands-dev] [Merge] lp:~widelands-dev/widelands/fix_tut1_destroy_quarries into lp:widelands
Review: Approve compile, play This was an easy one :-) -- https://code.launchpad.net/~widelands-dev/widelands/fix_tut1_destroy_quarries/+merge/294699 Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/fix_tut1_destroy_quarries. ___ Mailing list: https://launchpad.net/~widelands-dev Post to : widelands-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~widelands-dev More help : https://help.launchpad.net/ListHelp
Re: [Widelands-dev] [Merge] lp:~widelands-dev/widelands/fix_tut1_destroy_quarries into lp:widelands
Thanks! @bunnybot merge -- https://code.launchpad.net/~widelands-dev/widelands/fix_tut1_destroy_quarries/+merge/294699 Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/fix_tut1_destroy_quarries. ___ Mailing list: https://launchpad.net/~widelands-dev Post to : widelands-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~widelands-dev More help : https://help.launchpad.net/ListHelp
Re: [Widelands-dev] [Merge] lp:~widelands-dev/widelands/fix_tut1_destroy_quarries into lp:widelands
Umm, this kinda invalidates the following message box talking about having received multiple messages. Also, I think a much better fix would be to count messages tied to fields first_quarry_field and second_quarry_field. -- https://code.launchpad.net/~widelands-dev/widelands/fix_tut1_destroy_quarries/+merge/294699 Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/fix_tut1_destroy_quarries. ___ Mailing list: https://launchpad.net/~widelands-dev Post to : widelands-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~widelands-dev More help : https://help.launchpad.net/ListHelp
[Widelands-dev] [Merge] lp:~widelands-dev/widelands/fix_tut1_destroy_quarries into lp:widelands
The proposal to merge lp:~widelands-dev/widelands/fix_tut1_destroy_quarries into lp:widelands has been updated. Status: Needs review => Merged For more details, see: https://code.launchpad.net/~widelands-dev/widelands/fix_tut1_destroy_quarries/+merge/294699 -- Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/fix_tut1_destroy_quarries. ___ Mailing list: https://launchpad.net/~widelands-dev Post to : widelands-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~widelands-dev More help : https://help.launchpad.net/ListHelp
[Widelands-dev] [Merge] lp:~widelands-dev/widelands/fix_tut1_destroy_quarries_2 into lp:widelands
Miroslav Remák has proposed merging lp:~widelands-dev/widelands/fix_tut1_destroy_quarries_2 into lp:widelands. Requested reviews: Widelands Developers (widelands-dev) For more details, see: https://code.launchpad.net/~widelands-dev/widelands/fix_tut1_destroy_quarries_2/+merge/294713 The 'destroy_quarries_message' message box which is displayed after a quarry sends an "Out of rocks" message mentions receiving multiple messages. This merge request prevents triggering destroy_quarries_message immediately after the stones are taken away if the player had previously restored any archived message. -- Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/fix_tut1_destroy_quarries_2 into lp:widelands. === modified file 'data/campaigns/tutorial01_basic_control.wmf/scripting/mission_thread.lua' --- data/campaigns/tutorial01_basic_control.wmf/scripting/mission_thread.lua 2016-05-14 07:52:43 + +++ data/campaigns/tutorial01_basic_control.wmf/scripting/mission_thread.lua 2016-05-14 16:10:30 + @@ -332,8 +332,18 @@ -- Remove all rocks remove_all_rocks(first_quarry_field:region(6)) + function count_quarry_messages(field) + local count = 0 + for i, msg in ipairs(plr.messages) do + if (msg.field == first_quarry_field or msg.field == second_quarry_field) then +count = count + 1 + end + end + return count + end + -- Wait for messages to arrive - while #plr.inbox < 1 do sleep(300) end + while count_quarry_messages() < 2 do sleep(300) end local o = message_box_objective(plr, destroy_quarries_message) === modified file 'src/scripting/lua_game.cc' --- src/scripting/lua_game.cc 2016-03-14 19:56:14 + +++ src/scripting/lua_game.cc 2016-05-14 16:10:30 + @@ -108,6 +108,7 @@ PROP_RO(LuaPlayer, allowed_buildings), PROP_RO(LuaPlayer, objectives), PROP_RO(LuaPlayer, defeated), + PROP_RO(LuaPlayer, messages), PROP_RO(LuaPlayer, inbox), PROP_RW(LuaPlayer, team), PROP_RO(LuaPlayer, tribe), @@ -192,9 +193,29 @@ } /* RST + .. attribute:: messages + + (RO) An array of all the messages sent to the player. Note that you + can't add messages to this array, use :meth:`send_message` for that. +*/ +int LuaPlayer::get_messages(lua_State * L) { + Player & p = get(L, get_egbase(L)); + + lua_newtable(L); + uint32_t cidx = 1; + for (const auto& temp_message : p.messages()) { + lua_pushuint32(L, cidx ++); + to_lua(L, new LuaMessage(player_number(), temp_message.first)); + lua_rawset(L, -3); + } + + return 1; +} + +/* RST .. attribute:: inbox - (RO) An array of the message that are either read or new. Note that you + (RO) An array of the messages that are either read or new. Note that you can't add messages to this array, use :meth:`send_message` for that. */ int LuaPlayer::get_inbox(lua_State * L) { === modified file 'src/scripting/lua_game.h' --- src/scripting/lua_game.h 2016-04-03 08:01:49 + +++ src/scripting/lua_game.h 2016-05-14 16:10:30 + @@ -63,6 +63,7 @@ int get_allowed_buildings(lua_State * L); int get_objectives(lua_State * L); int get_defeated(lua_State * L); + int get_messages(lua_State * L); int get_inbox(lua_State * L); int get_team(lua_State * L); int get_tribe(lua_State * L); ___ Mailing list: https://launchpad.net/~widelands-dev Post to : widelands-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~widelands-dev More help : https://help.launchpad.net/ListHelp
[Widelands-dev] [Merge] lp:~widelands-dev/widelands/map_object_info into lp:widelands
Continuous integration builds have changed state: Travis build 1114. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/130181884. Appveyor build 951. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_map_object_info-951. -- https://code.launchpad.net/~widelands-dev/widelands/map_object_info/+merge/287409 Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/map_object_info. ___ Mailing list: https://launchpad.net/~widelands-dev Post to : widelands-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~widelands-dev More help : https://help.launchpad.net/ListHelp
Re: [Widelands-dev] [Merge] lp:~widelands-dev/widelands-website/encyclopedia into lp:widelands-website
Have you tried the wl_django1_8 branch? Even if some things won't work with this branch (mainly the third party apps) it should work for testing your changes. We could also try to submit my latest wlwebsite installation as a zipfile from me to you and you could try to use it. But i am not sure if this will work. Hopefully i get ready with wl_django1_8 in a few weeks... at least for testing on the alpha site. Adapting the third party apps to django 1.8 and including them as wl-apps isn't much work, (i believe). -- https://code.launchpad.net/~widelands-dev/widelands-website/encyclopedia/+merge/287410 Your team Widelands Developers is subscribed to branch lp:widelands-website. ___ Mailing list: https://launchpad.net/~widelands-dev Post to : widelands-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~widelands-dev More help : https://help.launchpad.net/ListHelp
[Widelands-dev] [Merge] lp:~widelands-dev/widelands/bug-1566441_Saving_game into lp:widelands
TiborB has proposed merging lp:~widelands-dev/widelands/bug-1566441_Saving_game into lp:widelands. Requested reviews: Widelands Developers (widelands-dev) Related bugs: Bug #1566441 in widelands: "String "Saving Game" appears too late " https://bugs.launchpad.net/widelands/+bug/1566441 For more details, see: https://code.launchpad.net/~widelands-dev/widelands/bug-1566441_Saving_game/+merge/294720 Making test "Saving game..." appear before actual saving taking place. -- Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/bug-1566441_Saving_game into lp:widelands. === modified file 'src/logic/game_controller.h' --- src/logic/game_controller.h 2016-01-05 09:54:44 + +++ src/logic/game_controller.h 2016-05-14 19:53:05 + @@ -79,6 +79,13 @@ virtual bool is_paused() = 0; /** + * Whether the game is stopped. + */ + bool is_paused_or_zero_speed() { + return is_paused() || real_speed() == 0; + }; + + /** * Sets whether the game is paused. */ virtual void set_paused(const bool paused) = 0; === modified file 'src/logic/save_handler.cc' --- src/logic/save_handler.cc 2016-03-08 15:21:41 + +++ src/logic/save_handler.cc 2016-05-14 19:53:05 + @@ -28,6 +28,7 @@ #include "base/log.h" #include "base/macros.h" #include "base/scoped_timer.h" +#include "base/time_string.h" #include "base/wexception.h" #include "game_io/game_saver.h" #include "io/filesystem/filesystem.h" @@ -53,15 +54,85 @@ return; } - if (save_requested_) { - if (!save_filename_.empty()) { - filename = save_filename_; - } - - log("Autosave: save requested : %s\n", filename.c_str()); - save_requested_ = false; - save_filename_ = ""; + // Are we saving now? + if (saving_next_tick_ || save_requested_) { + if (save_requested_) { + // Requested by user + if (!save_filename_.empty()) { +filename = save_filename_; + } + log("Gamesave: save requested: %s\n", filename.c_str()); + save_requested_ = false; + save_filename_ = ""; + } else { + // Autosave ... + // Roll savefiles + int32_t number_of_rolls = g_options.pull_section("global").get_int("rolling_autosave", 5) - 1; + log("Autosave: Rolling savefiles (count): %d\n", number_of_rolls + 1); + std::string filename_previous = +create_file_name(get_base_dir(), (boost::format("%s_%02d") % filename % number_of_rolls).str()); + if (number_of_rolls > 0 && g_fs->file_exists(filename_previous)) { +g_fs->fs_unlink(filename_previous); +log("Autosave: Deleted %s\n", filename_previous.c_str()); + } + number_of_rolls--; + while (number_of_rolls >= 0) { +const std::string filename_next = + create_file_name(get_base_dir(), + (boost::format("%s_%02d") % filename % number_of_rolls).str()); +if (g_fs->file_exists(filename_next)) { + g_fs->fs_rename(filename_next, filename_previous); + log("Autosave: Rolled %s to %s\n", filename_next.c_str(), filename_previous.c_str()); +} +filename_previous = filename_next; +number_of_rolls--; + } + filename = (boost::format("%s_00") % autosave_filename_).str(); + log("Autosave: saving as %s\n", filename.c_str()); + } + + // Saving now + const std::string complete_filename = create_file_name(get_base_dir(), filename); + std::string backup_filename; + + // always overwrite a file + if (g_fs->file_exists(complete_filename)) { + filename += "2"; + backup_filename = create_file_name (get_base_dir(), filename); + if (g_fs->file_exists(backup_filename)) { +g_fs->fs_unlink(backup_filename); + } + g_fs->fs_rename(complete_filename, backup_filename); + } + + std::string error; + if (!save_game(game, complete_filename, &error)) { + log("Autosave: ERROR! - %s\n", error.c_str()); + game.get_ibase()->log_message(_("Saving failed!")); + + // if backup file was created, move it back + if (backup_filename.length() > 0) { +if (g_fs->file_exists(complete_filename)) { + g_fs->fs_unlink(complete_filename); +} +g_fs->fs_rename(backup_filename, complete_filename); + } + // Wait 30 seconds until next save try + last_saved_realtime_ = last_saved_realtime_ + 3; + return; + } else { + // if backup file was created, time to remove it + if (backup_filename.length() > 0 && g_fs->file_exists(backup_filename)) +g_fs->fs_unlink(backup_filename); + } + + log("Autosave: save took %d ms\n", SDL_GetTicks() - realtime); + game.get_ibase()->log_message(_("Game saved")); + last_saved_realtime_ = realtime; + saving_next_tick_ = false; + } else { + // Perhaps save is due now? const int32_t autosave_interval_in_seconds = g_options.pull_section("global").get_int("autosave", DEFAULT_AUTOSAVE_INTERVAL * 60); if (autosave_interval_in_seconds <= 0) { @@ -73,76 +144,19 @@ return; } - if (game.game_controller()->is_paused()) { // check if game is paused + // check if game is paused (in any way) + if (game.game_controller()->is_paused_or_zero_speed()) {
Re: [Widelands-dev] [Merge] lp:~widelands-dev/widelands/fix_tut1_destroy_quarries_2 into lp:widelands
Excellent :) @bunnybot merge -- https://code.launchpad.net/~widelands-dev/widelands/fix_tut1_destroy_quarries_2/+merge/294713 Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/fix_tut1_destroy_quarries_2 into lp:widelands. ___ Mailing list: https://launchpad.net/~widelands-dev Post to : widelands-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~widelands-dev More help : https://help.launchpad.net/ListHelp
[Widelands-dev] [Merge] lp:~widelands-dev/widelands/fix_tut1_destroy_quarries_2 into lp:widelands
The proposal to merge lp:~widelands-dev/widelands/fix_tut1_destroy_quarries_2 into lp:widelands has been updated. Status: Needs review => Merged For more details, see: https://code.launchpad.net/~widelands-dev/widelands/fix_tut1_destroy_quarries_2/+merge/294713 -- Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/fix_tut1_destroy_quarries_2 into lp:widelands. ___ Mailing list: https://launchpad.net/~widelands-dev Post to : widelands-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~widelands-dev More help : https://help.launchpad.net/ListHelp
[Widelands-dev] [Merge] lp:~widelands-dev/widelands/bug-1418154-collectors-teams into lp:widelands
Continuous integration builds have changed state: Travis build 1120. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/130243262. Appveyor build 957. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bug_1418154_collectors_teams-957. -- https://code.launchpad.net/~widelands-dev/widelands/bug-1418154-collectors-teams/+merge/294702 Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/bug-1418154-collectors-teams into lp:widelands. ___ Mailing list: https://launchpad.net/~widelands-dev Post to : widelands-dev@lists.launchpad.net Unsubscribe : https://launchpad.net/~widelands-dev More help : https://help.launchpad.net/ListHelp