[Widelands-dev] [Merge] lp:~widelands-dev/widelands/bug-1838193-savedir into lp:widelands

2019-07-31 Thread noreply
The proposal to merge lp:~widelands-dev/widelands/bug-1838193-savedir into 
lp:widelands has been updated.

Status: Needs review => Merged

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/bug-1838193-savedir/+merge/370829
-- 
Your team Widelands Developers is requested to review the proposed merge of 
lp:~widelands-dev/widelands/bug-1838193-savedir 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-1838193-savedir into lp:widelands

2019-07-31 Thread bunnybot
Continuous integration builds have changed state:

Travis build 5293. State: passed. Details: 
https://travis-ci.org/widelands/widelands/builds/566082792.
Appveyor build 5067. State: success. Details: 
https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bug_1838193_savedir-5067.
-- 
https://code.launchpad.net/~widelands-dev/widelands/bug-1838193-savedir/+merge/370829
Your team Widelands Developers is requested to review the proposed merge of 
lp:~widelands-dev/widelands/bug-1838193-savedir 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


Re: [Widelands-dev] [Merge] lp:~widelands-dev/widelands/ai_flag_warehouse_distance into lp:widelands

2019-07-31 Thread TiborB
See my answer.


Diff comments:

> 
> === modified file 'src/ai/defaultai.cc'
> --- src/ai/defaultai.cc   2019-05-26 11:39:41 +
> +++ src/ai/defaultai.cc   2019-07-24 19:32:22 +
> @@ -3756,318 +3813,341 @@
>  // connection is not known
>  bool DefaultAI::create_shortcut_road(const Flag& flag,
>   uint16_t checkradius,
> - int16_t min_reduction,
>   uint32_t gametime) {
>  
> - // Increasing the failed_connection_tries counter
> - // At the same time it indicates a time an economy is without a 
> warehouse
> - EconomyObserver* eco = get_economy_observer(flag.economy());
> - // if we passed grace time this will be last attempt and if it fails
> - // building is destroyes
> - bool last_attempt_ = false;
> -
> - // this should not happen, but if the economy has a warehouse and a 
> dismantle
> - // grace time set, we must 'zero' the dismantle grace time
> - if (!flag.get_economy()->warehouses().empty() &&
> - eco->dismantle_grace_time != std::numeric_limits::max()) {
> - eco->dismantle_grace_time = 
> std::numeric_limits::max();
> - }
> -
> - // first we deal with situations when this is economy with no warehouses
> - // and this is a flag belonging to a building/constructionsite
> - // such economy must get dismantle grace time (if not set yet)
> - // end sometimes extended checkradius
> - if (flag.get_economy()->warehouses().empty() && flag.get_building()) {
> -
> - // occupied military buildings get special treatment
> - // (extended grace time + longer radius)
> - bool occupied_military_ = false;
> - Building* b = flag.get_building();
> - if (upcast(MilitarySite, militb, b)) {
> - if 
> (militb->soldier_control()->stationed_soldiers().size() > 0) {
> - occupied_military_ = true;
> - }
> - }
> -
> - // check if we are within grace time, if not or gracetime unset 
> we need to do something
> - // if we are within gracetime we do nothing (this loop is 
> skipped)
> -
> - // if grace time is not set, this is probably first time 
> without a warehouse and we must set
> - // it
> - if (eco->dismantle_grace_time == 
> std::numeric_limits::max()) {
> -
> - // constructionsites
> - if (upcast(ConstructionSite const, constructionsite, 
> flag.get_building())) {
> - BuildingObserver& bo =
> -
> get_building_observer(constructionsite->building().name().c_str());
> - // first very special case - a port (in the 
> phase of constructionsite)
> - // this might be a new colonization port
> - if (bo.is(BuildingAttribute::kPort)) {
> - eco->dismantle_grace_time = gametime + 
> 60 * 60 * 1000;  // one hour should be enough
> - } else {  // other constructionsites, usually 
> new (standalone) constructionsites
> - eco->dismantle_grace_time =
> -gametime + 30 * 1000 +// 
> very shot time is enough
> -(eco->flags.size() * 30 * 1000);  // 
> + 30 seconds for every flag in economy
> - }
> -
> - // buildings
> - } else {
> -
> - if (occupied_military_) {
> - eco->dismantle_grace_time =
> -(gametime + 90 * 60 * 1000) + 
> (eco->flags.size() * 20 * 1000);
> -
> - } else {  // for other normal buildings
> - eco->dismantle_grace_time =
> -gametime + (45 * 60 * 1000) + 
> (eco->flags.size() * 20 * 1000);
> - }
> - }
> -
> - // we have passed grace_time - it is time to dismantle
> - } else if (eco->dismantle_grace_time <= gametime) {
> - last_attempt_ = true;
> - // we increase a check radius in last attempt
> - checkradius += 2;
> - }
> -
> - // and bonus for occupied military buildings:
> - if (occupied_military_) {
> - checkradius += 4;
> - }
> -
> - // and generally increase radius for unconnected buildings
> - checkradius += 2;
> - }
> -
> - // Now own roadfinding stuff
> - const Map& map = game().map();
> -
> - // initializing new object of 

Re: [Widelands-dev] [Merge] lp:~widelands-dev/widelands/bug-1838193-savedir into lp:widelands

2019-07-31 Thread GunChleoc
@bunnybot merge
-- 
https://code.launchpad.net/~widelands-dev/widelands/bug-1838193-savedir/+merge/370829
Your team Widelands Developers is requested to review the proposed merge of 
lp:~widelands-dev/widelands/bug-1838193-savedir 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


Re: [Widelands-dev] [Merge] lp:~widelands-dev/widelands/toolbar-dropdown-menus into lp:widelands

2019-07-31 Thread GunChleoc
All issues mentioned in this discussion should be fixed now, except for loading 
a Tutorial 2 game, which I cannot reproduce. I don't expect that it has 
anything to do with this branch though, since I get similar messages for Build 
20 games in trunk.
-- 
https://code.launchpad.net/~widelands-dev/widelands/toolbar-dropdown-menus/+merge/368230
Your team Widelands Developers is subscribed to branch 
lp:~widelands-dev/widelands/toolbar-dropdown-scripting-review-only.

___
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-1838193-savedir into lp:widelands

2019-07-31 Thread GunChleoc
GunChleoc has proposed merging lp:~widelands-dev/widelands/bug-1838193-savedir 
into lp:widelands.

Commit message:
Ensure save directory exists when checking for campaigns progress.

Requested reviews:
  Widelands Developers (widelands-dev)
Related bugs:
  Bug #1838193 in widelands: "Single player campaigns no longer work"
  https://bugs.launchpad.net/widelands/+bug/1838193

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/bug-1838193-savedir/+merge/370829
-- 
Your team Widelands Developers is requested to review the proposed merge of 
lp:~widelands-dev/widelands/bug-1838193-savedir into lp:widelands.
=== modified file 'src/ui_fsmenu/campaigns.cc'
--- src/ui_fsmenu/campaigns.cc	2019-04-24 06:05:50 +
+++ src/ui_fsmenu/campaigns.cc	2019-07-31 16:38:24 +
@@ -37,6 +37,7 @@
 Campaigns::Campaigns() {
 	// Load solved scenarios
 	std::unique_ptr campvis;
+	g_fs->ensure_directory_exists(kSaveDir);
 	if (!(g_fs->file_exists(kCampVisFile))) {
 		// There is no campaigns.conf file - create one.
 		campvis.reset(new Profile(kCampVisFile.c_str()));

___
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/gcc9 into lp:widelands

2019-07-31 Thread GunChleoc
Jobs are green on AppVeyor - can somebody with a Windows machine please test 
before we merge?

https://ci.appveyor.com/project/widelands-dev/widelands/builds/26365811

-- 
https://code.launchpad.net/~widelands-dev/widelands/gcc9/+merge/370692
Your team Widelands Developers is requested to review the proposed merge of 
lp:~widelands-dev/widelands/gcc9 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


Re: [Widelands-dev] [Merge] lp:~widelands-dev/widelands/ai_flag_warehouse_distance into lp:widelands

2019-07-31 Thread GunChleoc
Code review done. Mostly small tweaks to names and some efficiency stuff, and 1 
real question.

Diff comments:

> 
> === modified file 'src/ai/ai_help_structs.cc'
> --- src/ai/ai_help_structs.cc 2019-04-09 16:43:49 +
> +++ src/ai/ai_help_structs.cc 2019-07-24 19:32:22 +
> @@ -1417,4 +1301,190 @@
>   return update_time;
>  }
>  
> +FlagWarehouseDistances::FlagInfo::FlagInfo(const uint32_t gametime,
> +   const uint16_t dist,
> +   const uint32_t wh) {
> + expiry_time = gametime + kFlagDistanceExpirationPeriod;
> + soft_expiry_time = gametime + kFlagDistanceExpirationPeriod / 2;
> + distance = dist;
> + nearest_warehouse = wh;
> + new_road_prohibited_till = 0;
> +}
> +FlagWarehouseDistances::FlagInfo::FlagInfo() {
> + expiry_time = 0;
> + distance = 1000;
> + new_road_prohibited_till = 0;
> +}
> +
> +// We are updating the distance info, but not all the time.
> +// Always if after soft expiration period, but
> +// if below expiration period only when the new value is lower than current 
> on

on -> one

> +// In both cases new expiration times are calculated
> +bool FlagWarehouseDistances::FlagInfo::update(const uint32_t gametime,
> +  const uint16_t new_distance,
> +  const uint32_t nearest_wh) {
> + const uint32_t new_expiry_time = gametime + 
> kFlagDistanceExpirationPeriod;
> +
> + if (gametime > soft_expiry_time) {
> + distance = new_distance;
> + expiry_time = new_expiry_time;
> + soft_expiry_time = gametime + kFlagDistanceExpirationPeriod / 2;
> + nearest_warehouse = nearest_wh;
> + return true;
> + } else if (new_distance < distance || (new_distance == distance &&
> +expiry_time < gametime + 
> kFlagDistanceExpirationPeriod)) {

expiry_time < new_expiry_time

> + distance = new_distance;
> + expiry_time = gametime + kFlagDistanceExpirationPeriod;

= new_expiry_time

> + nearest_warehouse = nearest_wh;
> + return true;
> + }
> + return false;
> +}
> +
> +uint16_t FlagWarehouseDistances::FlagInfo::get(const uint32_t gametime, 
> uint32_t* nw) const {
> + *nw = nearest_warehouse;
> + if (gametime <= expiry_time) {
> + return distance;
> + }
> + return kFarButReachable;
> +}
> +
> +void FlagWarehouseDistances::FlagInfo::road_built(const uint32_t gametime) {

Name it set_road_built

> + // Prohibiting for next 60 seconds
> + new_road_prohibited_till = gametime + 60 * 1000;
> +}
> +
> +bool FlagWarehouseDistances::FlagInfo::road_prohibited(const uint32_t 
> gametime) const {

name it is_road_prohibited

> + return new_road_prohibited_till > gametime;
> +}
> +
> +bool FlagWarehouseDistances::set_distance(const uint32_t flag_coords,
> +  const uint16_t distance,
> +  uint32_t const gametime,
> +  uint32_t const nearest_warehouse) {
> + if (flags_map.count(flag_coords) == 0) {
> + flags_map[flag_coords] =
> +FlagWarehouseDistances::FlagInfo(gametime, distance, 
> nearest_warehouse);
> + return true;
> + }
> + return flags_map[flag_coords].update(gametime, distance, 
> nearest_warehouse);
> +}
> +
> +uint16_t FlagWarehouseDistances::count() const {
> + return flags_map.size();
> +}
> +
> +int16_t
> +FlagWarehouseDistances::get_distance(const uint32_t flag_coords, uint32_t 
> gametime, uint32_t* nw) {

Make this function const

> + if (flags_map.count(flag_coords) == 0) {
> + *nw = 0;
> + return kFarButReachable;  // this is to discourage to build 
> second road from brand new flag...
> + } else {
> + return flags_map[flag_coords].get(gametime, nw);
> + }
> +}
> +
> +void FlagWarehouseDistances::set_road_built(const uint32_t coords_hash, 
> const uint32_t gametime) {
> + if (flags_map.count(coords_hash) == 1) {
> + flags_map[coords_hash].road_built(gametime);
> + }
> +}
> +
> +bool FlagWarehouseDistances::get_road_prohibited(const uint32_t coords_hash,

Naming it is_road_prohibited will make it clearer that it's a boolean.

> + const uint32_t gametime) {
> + if (flags_map.count(coords_hash) == 1) {
> + return flags_map[coords_hash].road_prohibited(gametime);
> + }
> + return false;
> +}
> +
> +bool FlagWarehouseDistances::remove_old_flag(uint32_t gametime) {
> + for (std::map::iterator it 
> = flags_map.begin();
> +  it != flags_map.end(); it++) {
> + if (it->second.expiry_time + kOldFlagRemoveTime < gametime) {
> + it = 

Re: [Widelands-dev] [Merge] lp:~widelands-dev/widelands/toolbar-dropdown-menus into lp:widelands

2019-07-31 Thread GunChleoc
Pause does not work in network games; the host has to use a chat command for 
that. Good catch - I'll remove pause game from the menu for multiplayer games.

We could always open multiple editor windows, so this is not new.
-- 
https://code.launchpad.net/~widelands-dev/widelands/toolbar-dropdown-menus/+merge/368230
Your team Widelands Developers is subscribed to branch 
lp:~widelands-dev/widelands/toolbar-dropdown-scripting-review-only.

___
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/pybb_attachments into lp:widelands-website

2019-07-31 Thread GunChleoc
> Everyone can rename 'image.js' into 'image.png'...

That's true. It would still be an advantage though if the browser then doesn't 
execute it.

Doing a full validation too is definitely a better idea.

> What about restricting uploads to users who have written x posts prior? 

Also a good idea
-- 
https://code.launchpad.net/~widelands-dev/widelands-website/pybb_attachments/+merge/370342
Your team Widelands Developers is requested to review the proposed merge of 
lp:~widelands-dev/widelands-website/pybb_attachments into 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


Re: [Widelands-dev] [Merge] lp:~widelands-dev/widelands/gcc9 into lp:widelands

2019-07-31 Thread GunChleoc
Thanks, Tino!

I have applied your changes to this branch now.
-- 
https://code.launchpad.net/~widelands-dev/widelands/gcc9/+merge/370692
Your team Widelands Developers is requested to review the proposed merge of 
lp:~widelands-dev/widelands/gcc9 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