Merge lp:~widelands-dev/widelands/bug-1525706-artifacts into lp:widelands

Proposed by GunChleoc
Status: Merged
Merged at revision: 7869
Proposed branch: lp:~widelands-dev/widelands/bug-1525706-artifacts
Merge into: lp:widelands
Diff against target: 49 lines (+10/-7)
3 files modified
src/editor/ui_menus/editor_main_menu_save_map.cc (+1/-1)
src/logic/map.cc (+6/-5)
src/logic/map.h (+3/-1)
To merge this branch: bzr merge lp:~widelands-dev/widelands/bug-1525706-artifacts
Reviewer Review Type Date Requested Status
TiborB Approve
kaputtnik (community) testing Approve
SirVer Needs Fixing
Review via email: mp+285566@code.launchpad.net

Commit message

Fixed checking for artifacts on a map.

Description of the change

The old function was semantic nonsense...

To post a comment you must log in.
Revision history for this message
kaputtnik (franku) wrote :

Seems to work properly now :-)

I got one crash after several load/save actions in the editor, but i don't know if this is related to this branch or in general to bug 1543944. The crash happens after loading a map and the output says:

WidelandsMapLoader::load_map_complete() took 356ms
widelands: /home/kaputtnik/Quellcode/widelands-repo/bug-1525706-artifacts/src/logic/map.h:510: static Widelands::MapIndex Widelands::Map::get_index(const Widelands::Coords&, int16_t): Assertion `c.x < width' failed.
Abgebrochen (Speicherabzug geschrieben)

It would be nice if MapLoader and MapSaver also writes the name of the map to the output. It is hard to remember which map was saved/loaded when one often loads and saves much maps.

Revision history for this message
GunChleoc (gunchleoc) wrote :

This changed function is only called during saving, and it only adds a tag or not, so it's not related to the crash. Good idea of adding the map name to the output though; I will look into it.

Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 656. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/108226507.
Appveyor build 512. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bug_1525706_artifacts-512.

Revision history for this message
kaputtnik (franku) wrote :

> Good idea of adding the map name to the output though; I will look into it.

If possible please also add the current widelands version to the output. I am always searching for it and have to start widelands (or investigate the VERSION file) to get it.

Revision history for this message
SirVer (sirver) wrote :

I suggest to simplify the code.

review: Needs Fixing
Revision history for this message
kaputtnik (franku) wrote :

Another crash in menu load map when trying to select a map. First crash was when pointing on map "Ice wars", second time when trying select map "Sun of Fire":

<error: Cannot access memory at address 0x7473656767755300>

backtrace from first crash attached to bug report.

Revision history for this message
kaputtnik (franku) wrote :

Oh i see now that this crash happens also in trunk r7816.

Revision history for this message
GunChleoc (gunchleoc) wrote :

As I said before, there are no possible map loading crashes related to this branch. This code is only executed while saving a map, and then the only thing it does is write the "artifacts" tag.

I tried and failed to just iterate over the fields - seems like there is no way to safely get the size of a std::unique_ptr<array[]>.

Why is it an array and not a vector anyway?

Revision history for this message
kaputtnik (franku) wrote :

I have lost overview :-S "Lost in bugs" :-D Sorry

Revision history for this message
GunChleoc (gunchleoc) wrote :

As long as I am not lost in translation, which would be bad for my job... :P

Revision history for this message
kaputtnik (franku) wrote :

Merged with trunk an looks good.

review: Approve (testing)
Revision history for this message
GunChleoc (gunchleoc) wrote :

I still need help with this before we can go ahead:

> I tried and failed to just iterate over the fields - seems like there is no
> way to safely get the size of a std::unique_ptr<array[]>.
>
> Why is it an array and not a vector anyway?

Revision history for this message
GunChleoc (gunchleoc) wrote :

I have found a safe upper limit for iterating over the fields now, so I'll be pushing something new as soon as I have compiled & tested it.

Revision history for this message
SirVer (sirver) wrote :

Sorry, cannot keep up with email....

I think this can be a vector and that would probably be better.

> Am 16.02.2016 um 09:48 schrieb GunChleoc <email address hidden>:
>
> I still need help with this before we can go ahead:
>
>> I tried and failed to just iterate over the fields - seems like there is no
>> way to safely get the size of a std::unique_ptr<array[]>.
>>
>> Why is it an array and not a vector anyway?
> --
> https://code.launchpad.net/~widelands-dev/widelands/bug-1525706-artifacts/+merge/285566
> Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/bug-1525706-artifacts.
>
> _______________________________________________
> Mailing list: https://launchpad.net/~widelands-dev
> Post to : <email address hidden>
> Unsubscribe : https://launchpad.net/~widelands-dev
> More help : https://help.launchpad.net/ListHelp

Revision history for this message
bunnybot (widelandsofficial) wrote :

Bunnybot encountered an error while working on this merge proposal:

Running 'bzr pull --overwrite' failed. Output:

Permission denied (publickey).
ConnectionReset reading response for 'BzrDir.open_2.1', retrying
Permission denied (publickey).
bzr: ERROR: Connection closed: Unexpected end of message. Please check connectivity and permissions, and report a bug if problems persist.
Using saved parent location: bzr+ssh://bazaar.launchpad.net/~widelands-dev/widelands/bug-1525706-artifacts/

Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 734. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/110444117.
Appveyor build 581. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bug_1525706_artifacts-581.

Revision history for this message
kaputtnik (franku) wrote :

Works :-)

review: Approve (testing)
Revision history for this message
bunnybot (widelandsofficial) wrote :

Bunnybot encountered an error while working on this merge proposal:

Running 'bzr pull --overwrite' failed. Output:

ssh_exchange_identification: Connection closed by remote host
ConnectionReset reading response for 'BzrDir.open_2.1', retrying
ssh_exchange_identification: Connection closed by remote host
bzr: ERROR: Connection closed: Unexpected end of message. Please check connectivity and permissions, and report a bug if problems persist.
Using saved parent location: bzr+ssh://bazaar.launchpad.net/~widelands-dev/widelands/bug-1525706-artifacts/

Revision history for this message
bunnybot (widelandsofficial) wrote :

Bunnybot encountered an error while working on this merge proposal:

Running 'bzr pull --overwrite' failed. Output:

ssh_exchange_identification: Connection closed by remote host
ConnectionReset reading response for 'BzrDir.open_2.1', retrying
ssh_exchange_identification: Connection closed by remote host
bzr: ERROR: Connection closed: Unexpected end of message. Please check connectivity and permissions, and report a bug if problems persist.
Using saved parent location: bzr+ssh://bazaar.launchpad.net/~widelands-dev/widelands/bug-1525706-artifacts/

Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 734. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/110444117.
Appveyor build 581. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bug_1525706_artifacts-581.

Revision history for this message
GunChleoc (gunchleoc) wrote :

Changing this to a vector is complicated, so I'd like to get this branch in and leave that as a problem for another day.

> Sorry, cannot keep up with email....
>
> I think this can be a vector and that would probably be better.

Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 768. State: failed. Details: https://travis-ci.org/widelands/widelands/builds/111303303.
Appveyor build 614. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bug_1525706_artifacts-614.

Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 768. State: failed. Details: https://travis-ci.org/widelands/widelands/builds/111303303.
Appveyor build 614. State: failed. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bug_1525706_artifacts-614.

Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 769. State: failed. Details: https://travis-ci.org/widelands/widelands/builds/111429590.
Appveyor build 615. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bug_1525706_artifacts-615.

Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 787. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/112800339.
Appveyor build 633. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bug_1525706_artifacts-633.

Revision history for this message
TiborB (tiborb95) wrote :

Code looks good

review: Approve
Revision history for this message
GunChleoc (gunchleoc) wrote :

Thanks!

@bunnybot merge

Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 802. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/113182182.
Appveyor build 648. State: failed. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_bug_1525706_artifacts-648.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/editor/ui_menus/editor_main_menu_save_map.cc'
2--- src/editor/ui_menus/editor_main_menu_save_map.cc 2016-02-22 10:23:14 +0000
3+++ src/editor/ui_menus/editor_main_menu_save_map.cc 2016-03-02 17:09:33 +0000
4@@ -271,7 +271,7 @@
5 map.delete_tag("seafaring");
6 }
7
8- if (map.has_artifacts(egbase.world())) {
9+ if (map.has_artifacts()) {
10 map.add_tag("artifacts");
11 } else {
12 map.delete_tag("artifacts");
13
14=== modified file 'src/logic/map.cc'
15--- src/logic/map.cc 2016-03-02 10:04:54 +0000
16+++ src/logic/map.cc 2016-03-02 17:09:33 +0000
17@@ -2129,11 +2129,12 @@
18 return false;
19 }
20
21-bool Map::has_artifacts(const World& world) {
22- for (int32_t i = 0; i < world.get_nr_immovables(); ++i) {
23- const ImmovableDescr& descr = *world.get_immovable_descr(i);
24- if (descr.has_attribute(descr.get_attribute_id("artifact"))) {
25- return true;
26+bool Map::has_artifacts() {
27+ for (MapIndex i = 0; i < max_index(); ++i) {
28+ if (upcast(Immovable, immovable, fields_[i].get_immovable())) {
29+ if (immovable->descr().has_attribute(immovable->descr().get_attribute_id("artifact"))) {
30+ return true;
31+ }
32 }
33 }
34 return false;
35
36=== modified file 'src/logic/map.h'
37--- src/logic/map.h 2016-02-16 13:15:29 +0000
38+++ src/logic/map.h 2016-03-02 17:09:33 +0000
39@@ -433,7 +433,9 @@
40 const PortSpacesSet& get_port_spaces() const {return port_spaces_;}
41 std::vector<Coords> find_portdock(const Widelands::Coords& c) const;
42 bool allows_seafaring();
43- bool has_artifacts(const World& world);
44+
45+ /// Checks whether there are any artifacts on the map
46+ bool has_artifacts();
47
48 protected: /// These functions are needed in Testclasses
49 void set_size(uint32_t w, uint32_t h);

Subscribers

People subscribed via source and target branches

to status/vote changes: