Merge lp:~widelands-dev/widelands/fix-bug-1208130 into lp:widelands

Proposed by cghislai
Status: Merged
Merged at revision: 6715
Proposed branch: lp:~widelands-dev/widelands/fix-bug-1208130
Merge into: lp:widelands
Diff against target: 127 lines (+35/-25)
3 files modified
src/wui/buildingwindow.cc (+1/-19)
src/wui/buildingwindow.h (+0/-2)
src/wui/soldierlist.cc (+34/-4)
To merge this branch: bzr merge lp:~widelands-dev/widelands/fix-bug-1208130
Reviewer Review Type Date Requested Status
Nasenbaer Approve
Teppo Mäenpää Needs Resubmitting
SirVer Needs Fixing
Review via email: mp+179293@code.launchpad.net

Description of the change

I suggest merging Teppo's fix to the desync issue with soldiers preference. It has been tested

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

This has conflicts with master - hard to see what you actually changed.

review: Needs Fixing
Revision history for this message
Teppo Mäenpää (kxq) wrote :

Hi, I have now merged trunk/6711 to this branch for a re-review.

About the merge conflict:
There was a line saying " if ( !workarea_info.size() ) return ; show_workarea();"
code checker complained about it.
I had changed that to " if ( workarea_info.empty() ) return ; show_workarea();"
In trunk it was changed to " if ( !workarea_info.empty() ) return ; show_workarea();"
As these two modifications applied to the same line were not the same, there was a conflict.

I prefer my fix in the conflicting line better, as in current trunk the workarea is shown only when there is no workarea, while here it works, as before. Of course, my view could be biased.

Do you see it a bad thing, if people like me piggy-back some compiler/codechecker warning fixes to other fixes?

=================================

What was changed:

- Removed dead code from buildingwindow (methods void act_prefer_rookies() and act_prefer_heroes() )
- Changed the soldier list so that only player can click the preference button
- Changed the soldier to use the command relay function instead of directly changing the militarysite, to avoid desyncs in multiplayer games.
- Something I did not do, presumably Charly also figured out to keep the preference-tab up-to-date for observers ?

review: Needs Resubmitting
Revision history for this message
Teppo Mäenpää (kxq) wrote :

About the last bullet in the list of changes above: Yes, the preference stays in synch now -- I forgot to fix that line in my comment. It takes me about one hour to compile widelands, so I wrote the above text while waiting for miracles to happen.. SirVer, please re-review this branch, and merge if you find it OK.

Revision history for this message
SirVer (sirver) wrote :

One hour!!?!?! Oh wow. Are you using ccache? http://ccache.samba.org/ . It takes me < 5 minutes to make a fresh build after a make clean.

I will review as soons as I find some energy for this. Thanks for working on this Teppo.

Revision history for this message
Teppo Mäenpää (kxq) wrote :

Widelands is the most heavy-weight application I have ever used (off-work, that is), by a wide margin. My computer is just slow, CPU-wise. It only hurts when working with widelands, in all other cases I prefer my no-moving-parts-except-in-the-keyboard approach. It is faster than raspberrypi.. Normal computers make horrible sounds. To be honest, I have considered buying a normal computer just to speed WL (both game and compilation) up.

I do not think that any software solutions can overcome that. Turning some optimizations off in debug builds might help.

Revision history for this message
Nasenbaer (nasenbaer) wrote :

Looks perfectly fine to me :).
Thank you for the fix Teppo!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/wui/buildingwindow.cc'
--- src/wui/buildingwindow.cc 2013-08-10 16:57:13 +0000
+++ src/wui/buildingwindow.cc 2013-08-11 03:39:50 +0000
@@ -423,24 +423,6 @@
423 die();423 die();
424}424}
425425
426void Building_Window::act_prefer_rookies()
427{
428 if (is_a(Widelands::MilitarySite, &m_building))
429 igbase().game().send_player_militarysite_set_soldier_preference
430 (m_building, Widelands::MilitarySite::kPrefersRookies);
431
432 die();
433}
434
435void
436Building_Window::act_prefer_heroes()
437{
438 if (is_a(Widelands::MilitarySite, &m_building))
439 igbase().game().send_player_militarysite_set_soldier_preference
440 (m_building, Widelands::MilitarySite::kPrefersHeroes);
441
442 die();
443}
444426
445/**427/**
446===============428===============
@@ -501,7 +483,7 @@
501 } else {483 } else {
502 workarea_info = m_building.descr().m_workarea_info;484 workarea_info = m_building.descr().m_workarea_info;
503 }485 }
504 if (!workarea_info.empty()) {486 if (workarea_info.empty()) {
505 return;487 return;
506 }488 }
507 m_workarea_job_id = igbase().show_work_area(workarea_info, m_building.get_position());489 m_workarea_job_id = igbase().show_work_area(workarea_info, m_building.get_position());
508490
=== modified file 'src/wui/buildingwindow.h'
--- src/wui/buildingwindow.h 2013-08-02 14:20:21 +0000
+++ src/wui/buildingwindow.h 2013-08-11 03:39:50 +0000
@@ -66,8 +66,6 @@
66 void toggle_workarea();66 void toggle_workarea();
67 void configure_workarea_button();67 void configure_workarea_button();
68 void act_start_stop();68 void act_start_stop();
69 void act_prefer_rookies();
70 void act_prefer_heroes();
71 void act_start_or_cancel_expedition();69 void act_start_or_cancel_expedition();
72 void act_enhance(Widelands::Building_Index);70 void act_enhance(Widelands::Building_Index);
73 void clicked_goto();71 void clicked_goto();
7472
=== modified file 'src/wui/soldierlist.cc'
--- src/wui/soldierlist.cc 2013-07-27 10:35:55 +0000
+++ src/wui/soldierlist.cc 2013-08-11 03:39:50 +0000
@@ -368,6 +368,7 @@
368 void mouseover(const Soldier * soldier);368 void mouseover(const Soldier * soldier);
369 void eject(const Soldier * soldier);369 void eject(const Soldier * soldier);
370 void set_soldier_preference(int32_t changed_to);370 void set_soldier_preference(int32_t changed_to);
371 void think();
371372
372 Interactive_GameBase & m_igb;373 Interactive_GameBase & m_igb;
373 Widelands::Building & m_building;374 Widelands::Building & m_building;
@@ -406,6 +407,7 @@
406407
407 UI::Box * buttons = new UI::Box(this, 0, 0, UI::Box::Horizontal);408 UI::Box * buttons = new UI::Box(this, 0, 0, UI::Box::Horizontal);
408409
410 bool can_act = m_igb.can_act(m_building.owner().player_number());
409 if (upcast(Widelands::MilitarySite, ms, &building)) {411 if (upcast(Widelands::MilitarySite, ms, &building)) {
410 m_soldier_preference.add_button412 m_soldier_preference.add_button
411 (buttons, Point(0, 0), g_gr->images().get("pics/prefer_rookies.png"), _("Prefer Rookies"));413 (buttons, Point(0, 0), g_gr->images().get("pics/prefer_rookies.png"), _("Prefer Rookies"));
@@ -421,8 +423,12 @@
421 if (ms->get_soldier_preference() == Widelands::MilitarySite::kPrefersHeroes) {423 if (ms->get_soldier_preference() == Widelands::MilitarySite::kPrefersHeroes) {
422 m_soldier_preference.set_state(1);424 m_soldier_preference.set_state(1);
423 }425 }
424 m_soldier_preference.changedto.connect426 if (can_act) {
425 (boost::bind(&SoldierList::set_soldier_preference, this, _1));427 m_soldier_preference.changedto.connect
428 (boost::bind(&SoldierList::set_soldier_preference, this, _1));
429 } else {
430 m_soldier_preference.set_enabled(false);
431 }
426 }432 }
427 buttons->add_inf_space();433 buttons->add_inf_space();
428 buttons->add434 buttons->add
@@ -437,6 +443,28 @@
437 return *dynamic_cast<SoldierControl *>(&m_building);443 return *dynamic_cast<SoldierControl *>(&m_building);
438}444}
439445
446void SoldierList::think()
447{
448 // Only update the soldiers pref radio if player is spectator
449 if (m_igb.can_act(m_building.owner().player_number())) {
450 return;
451 }
452 if (upcast(Widelands::MilitarySite, ms, &m_building)) {
453 switch (ms->get_soldier_preference()) {
454 case Widelands::MilitarySite::kPrefersRookies:
455 m_soldier_preference.set_state(0);
456 break;
457 case Widelands::MilitarySite::kPrefersHeroes:
458 m_soldier_preference.set_state(1);
459 break;
460 default:
461 m_soldier_preference.set_state(-1);
462 break;
463 }
464 }
465}
466
467
440void SoldierList::mouseover(const Soldier * soldier)468void SoldierList::mouseover(const Soldier * soldier)
441{469{
442 if (!soldier) {470 if (!soldier) {
@@ -474,8 +502,10 @@
474void SoldierList::set_soldier_preference(int32_t changed_to) {502void SoldierList::set_soldier_preference(int32_t changed_to) {
475 upcast(Widelands::MilitarySite, ms, &m_building);503 upcast(Widelands::MilitarySite, ms, &m_building);
476 assert(ms);504 assert(ms);
477 ms->set_soldier_preference505 m_igb.game().send_player_militarysite_set_soldier_preference
478 (changed_to == 0 ? Widelands::MilitarySite::kPrefersRookies : Widelands::MilitarySite::kPrefersHeroes);506 (m_building, changed_to == 0 ?
507 Widelands::MilitarySite::kPrefersRookies:
508 Widelands::MilitarySite::kPrefersHeroes);
479}509}
480510
481UI::Panel * create_soldier_list511UI::Panel * create_soldier_list

Subscribers

People subscribed via source and target branches

to status/vote changes: