widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #00986
[Merge] lp:~widelands-dev/widelands/bug995011 into lp:widelands
Nicolai Hähnle has proposed merging lp:~widelands-dev/widelands/bug995011 into lp:widelands.
Requested reviews:
Widelands Developers (widelands-dev)
Related bugs:
Bug #995011 in widelands: "They can attack me but I can't attack them"
https://bugs.launchpad.net/widelands/+bug/995011
For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/bug995011/+merge/147776
I'm going to be super-consistent about this now and just put up a merge proposal even for a small change like this. I'm curious how that plays out as a process?
--
https://code.launchpad.net/~widelands-dev/widelands/bug995011/+merge/147776
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/bug995011 into lp:widelands.
=== modified file 'src/logic/findimmovable.cc'
--- src/logic/findimmovable.cc 2013-02-10 19:36:24 +0000
+++ src/logic/findimmovable.cc 2013-02-11 21:24:31 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008-2009 by the Widelands Development Team
+ * Copyright (C) 2008-2013 by the Widelands Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -24,6 +24,8 @@
#include "militarysite.h"
#include "upcast.h"
+#include "economy/flag.h"
+
namespace Widelands {
struct FindImmovableAlwaysTrueImpl {
@@ -71,4 +73,14 @@
return false;
}
+bool FindFlagOf::accept(const BaseImmovable & baseimm) const {
+ if (upcast(const Flag, flag, &baseimm)) {
+ if (Building * building = flag->get_building()) {
+ if (finder_.accept(*building))
+ return true;
+ }
+ }
+ return false;
}
+
+} // namespace Widelands
=== modified file 'src/logic/findimmovable.h'
--- src/logic/findimmovable.h 2013-02-10 19:36:24 +0000
+++ src/logic/findimmovable.h 2013-02-11 21:24:31 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008-2009 by the Widelands Development Team
+ * Copyright (C) 2008-2013 by the Widelands Development Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -131,8 +131,15 @@
const Immovable_Descr & descr;
};
-
-
-}
+struct FindFlagOf {
+ FindFlagOf(const FindImmovable & finder) : finder_(finder) {}
+
+ bool accept(const BaseImmovable &) const;
+
+ FindImmovable finder_;
+};
+
+
+} // namespace Widelands
#endif
=== modified file 'src/logic/player.cc'
--- src/logic/player.cc 2013-02-10 19:36:24 +0000
+++ src/logic/player.cc 2013-02-11 21:24:31 +0000
@@ -797,22 +797,22 @@
soldiers->clear();
Map & map = egbase().map();
- std::vector<BaseImmovable *> immovables;
+ std::vector<BaseImmovable *> flags;
map.find_reachable_immovables_unique
(Area<FCoords>(map.get_fcoords(flag.get_position()), 25),
- immovables,
- CheckStepWalkOn(MOVECAPS_WALK, false),
- FindImmovablePlayerMilitarySite(*this));
+ flags,
+ CheckStepDefault(MOVECAPS_WALK),
+ FindFlagOf(FindImmovablePlayerMilitarySite(*this)));
- if (immovables.empty())
+ if (flags.empty())
return 0;
- container_iterate_const(std::vector<BaseImmovable *>, immovables, i) {
- const MilitarySite & ms =
- ref_cast<MilitarySite, BaseImmovable>(**i.current);
- std::vector<Soldier *> const present = ms.presentSoldiers();
- uint32_t const nr_staying = ms.minSoldierCapacity();
+ container_iterate_const(std::vector<BaseImmovable *>, flags, i) {
+ const Flag * flag = static_cast<Flag *>(*i.current);
+ const MilitarySite * ms = static_cast<MilitarySite *>(flag->get_building());
+ std::vector<Soldier *> const present = ms->presentSoldiers();
+ uint32_t const nr_staying = ms->minSoldierCapacity();
uint32_t const nr_present = present.size();
if (nr_staying < nr_present) {
uint32_t const nr_taken =
Follow ups