Merge lp:~aber/widelands/bug984110 into lp:widelands

Proposed by David Allwicher
Status: Merged
Merged at revision: 6362
Proposed branch: lp:~aber/widelands/bug984110
Merge into: lp:widelands
Diff against target: 59 lines (+16/-12)
1 file modified
src/ai/defaultai.cc (+16/-12)
To merge this branch: bzr merge lp:~aber/widelands/bug984110
Reviewer Review Type Date Requested Status
Widelands Developers Pending
Review via email: mp+103729@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/ai/defaultai.cc'
--- src/ai/defaultai.cc 2012-04-04 14:06:44 +0000
+++ src/ai/defaultai.cc 2012-04-26 16:23:01 +0000
@@ -1412,7 +1412,7 @@
1412}1412}
14131413
14141414
1415/// connects a specific flag to another economy1415// connects a specific flag to another economy
1416bool DefaultAI::connect_flag_to_another_economy (const Flag & flag)1416bool DefaultAI::connect_flag_to_another_economy (const Flag & flag)
1417{1417{
1418 FindNodeWithFlagOrRoad functor;1418 FindNodeWithFlagOrRoad functor;
@@ -1431,20 +1431,22 @@
1431 return false;1431 return false;
14321432
1433 // then choose the one with the shortest path1433 // then choose the one with the shortest path
1434 Path & path = *new Path();;1434 Path * path = new Path();
1435 bool found = false;1435 bool found = false;
1436 check.set_openend(false);1436 check.set_openend(false);
1437 Coords closest;1437 Coords closest;
1438 container_iterate_const(std::vector<Coords>, reachable, i) {1438 container_iterate_const(std::vector<Coords>, reachable, i) {
1439 Path & path2 = *new Path();1439 Path * path2 = new Path();
1440 if (map.findpath(flag.get_position(), *i.current, 0, path2, check) < 0)1440 if (map.findpath(flag.get_position(), *i.current, 0, *path2, check) >= 0) {
1441 continue;1441 if (!found || path->get_nsteps() > path2->get_nsteps()) {
14421442 delete path;
1443 if (!found || path.get_nsteps() > path2.get_nsteps()) {1443 path = path2;
1444 path = path2;1444 path2 = NULL;
1445 closest = *i.current;1445 closest = *i.current;
1446 found = true;1446 found = true;
1447 }
1447 }1448 }
1449 delete path2;
1448 }1450 }
14491451
1450 if (found) {1452 if (found) {
@@ -1453,10 +1455,12 @@
1453 game().send_player_build_flag(player_number(), closest);1455 game().send_player_build_flag(player_number(), closest);
14541456
1455 // and finally build the road1457 // and finally build the road
1456 game().send_player_build_road(player_number(), path);1458 game().send_player_build_road(player_number(), *path);
1457 return true;1459 return true;
1460 } else {
1461 delete path;
1462 return false;
1458 }1463 }
1459 return false;
1460}1464}
14611465
1462/// adds alternative ways to already existing ones1466/// adds alternative ways to already existing ones

Subscribers

People subscribed via source and target branches

to status/vote changes: