Skip to content

Commit

Permalink
Don't access turn button from within the client FSM
Browse files Browse the repository at this point in the history
The game fsm shouldn't be aware of the fact that there is a UI
available.
  • Loading branch information
adrianbroher committed Jun 24, 2015
1 parent 2b19737 commit 75d51a8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
14 changes: 0 additions & 14 deletions UI/MapWnd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4669,20 +4669,6 @@ bool MapWnd::ReturnToMap() {
}

bool MapWnd::EndTurn() {
DebugLogger() << "MapWnd::EndTurn";
const Empire *empire = GetEmpire(HumanClientApp::GetApp()->EmpireID());
if (empire) {
double RP = empire->ResourceProduction(RE_RESEARCH);
double PP = empire->ResourceProduction(RE_INDUSTRY);
int turn_number = CurrentTurn();
float ratio = (RP/(PP+0.0001));
const GG::Clr color = empire->Color();
DebugLogger() << "Current Output (turn " << turn_number << ") RP/PP: " << ratio << " (" << RP << "/" << PP << ")";
DebugLogger() << "EmpireColors: " << static_cast<int>(color.r)
<< " " << static_cast<int>(color.g)
<< " " << static_cast<int>(color.b)
<< " " << static_cast<int>(color.a);
}
HumanClientApp::GetApp()->StartTurn();
return true;
}
Expand Down
16 changes: 16 additions & 0 deletions client/human/HumanClientApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,22 @@ float HumanClientApp::GLVersion() const
{ return GetGLVersion(); }

void HumanClientApp::StartTurn() {
DebugLogger() << "HumanClientApp::StartTurn";

const Empire *empire = GetEmpire(EmpireID());
if (empire) {
double RP = empire->ResourceProduction(RE_RESEARCH);
double PP = empire->ResourceProduction(RE_INDUSTRY);
int turn_number = CurrentTurn();
float ratio = (RP/(PP+0.0001));
const GG::Clr color = empire->Color();
DebugLogger() << "Current Output (turn " << turn_number << ") RP/PP: " << ratio << " (" << RP << "/" << PP << ")";
DebugLogger() << "EmpireColors: " << static_cast<int>(color.r)
<< " " << static_cast<int>(color.g)
<< " " << static_cast<int>(color.b)
<< " " << static_cast<int>(color.a);
}

ClientApp::StartTurn();
m_fsm->process_event(TurnEnded());
}
Expand Down
2 changes: 1 addition & 1 deletion client/human/HumanClientFSM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ boost::statechart::result PlayingTurn::react(const SaveGame& msg) {
}

boost::statechart::result PlayingTurn::react(const AdvanceTurn& d) {
Client().GetClientUI()->GetMapWnd()->m_btn_turn->LeftClickedSignal();
Client().StartTurn();
return discard_event();
}

Expand Down

0 comments on commit 75d51a8

Please sign in to comment.