Skip to content

Commit

Permalink
Fix soldier transfer
Browse files Browse the repository at this point in the history
Also fixes some typos and lint errors
  • Loading branch information
luiscamara committed Jan 18, 2023
1 parent 7976e35 commit 995e21a
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 40 deletions.
4 changes: 2 additions & 2 deletions game/state/city/agentmission.cpp
Expand Up @@ -386,11 +386,11 @@ void AgentMission::start(GameState &state, Agent &a)
{&state, a.shared_from_this()}));
a.recentlyHired = false;
}
if (a.recentryTransferred)
if (a.recentlyTransferred)
{
fw().pushEvent(new GameAgentEvent(GameEventType::AgentArrived,
{&state, a.shared_from_this()}, true));
a.recentryTransferred = false;
a.recentlyTransferred = false;
}
return;
}
Expand Down
2 changes: 1 addition & 1 deletion game/state/gamestate_serialize.xml
Expand Up @@ -244,7 +244,7 @@
<member>trainingPsiTicksAccumulated</member>
<member>trainingAssignment</member>
<member>recentlyHired</member>
<member>recentryTransferred</member>
<member>recentlyTransferred</member>
<member>recentlyFought</member>
<member>healingProgress</member>
<member>owner</member>
Expand Down
2 changes: 1 addition & 1 deletion game/state/shared/agent.cpp
Expand Up @@ -397,7 +397,7 @@ void Agent::transfer(GameState &state, StateRef<Building> newHome)
{
homeBuilding = newHome;
recentlyHired = false;
recentryTransferred = true;
recentlyTransferred = true;
assigned_to_lab = false;
setMission(state, AgentMission::gotoBuilding(state, *this, newHome, false, true));
}
Expand Down
2 changes: 1 addition & 1 deletion game/state/shared/agent.h
Expand Up @@ -96,7 +96,7 @@ class Agent : public StateObject<Agent>,
TrainingAssignment trainingAssignment = TrainingAssignment::None;

bool recentlyHired = false;
bool recentryTransferred = false;
bool recentlyTransferred = false;
bool recentlyFought = false;
float healingProgress = 0.0f;

Expand Down
61 changes: 26 additions & 35 deletions game/ui/base/transferscreen.cpp
Expand Up @@ -517,22 +517,7 @@ void TransferScreen::executeOrders()
case TransactionControl::Type::Soldier:
{
StateRef<Agent> agent{state.get(), c->itemId};
if (agent->homeBuilding != newBase->building)
{
agent->homeBuilding = newBase->building;
if (agent->currentBuilding != agent->homeBuilding ||
(agent->currentVehicle &&
agent->currentVehicle->currentBuilding != agent->homeBuilding))
{
if (agent->currentVehicle)
{
agent->enterBuilding(*state,
agent->currentVehicle->currentBuilding);
}
agent->setMission(*state,
AgentMission::gotoBuilding(*state, *agent));
}
}
agent->transfer(*state, newBase->building);
break;
}
case TransactionControl::Type::Vehicle:
Expand Down Expand Up @@ -673,25 +658,31 @@ void TransferScreen::initViewSecondBase()
view->setImage(viewImage);
view->setDepressedImage(viewImage);
wp<GraphicButton> weakView(view);
view->addCallback(FormEventType::ButtonClick, [this, weakView](FormsEvent *e) {
auto base = e->forms().RaisedBy->getData<Base>();
if (this->second_base != base)
{
this->changeSecondBase(base);
this->currentSecondView = weakView.lock();
}
});
view->addCallback(FormEventType::MouseEnter, [this](FormsEvent *e) {
auto base = e->forms().RaisedBy->getData<Base>();
this->textViewSecondBase->setText(base->name);
this->textViewSecondBase->setVisible(true);
this->textViewSecondBaseStatic->setVisible(false);
});
view->addCallback(FormEventType::MouseLeave, [this](FormsEvent *) {
// this->textViewSecondBase->setText("");
this->textViewSecondBase->setVisible(false);
this->textViewSecondBaseStatic->setVisible(true);
});
view->addCallback(FormEventType::ButtonClick,
[this, weakView](FormsEvent *e)
{
auto base = e->forms().RaisedBy->getData<Base>();
if (this->second_base != base)
{
this->changeSecondBase(base);
this->currentSecondView = weakView.lock();
}
});
view->addCallback(FormEventType::MouseEnter,
[this](FormsEvent *e)
{
auto base = e->forms().RaisedBy->getData<Base>();
this->textViewSecondBase->setText(base->name);
this->textViewSecondBase->setVisible(true);
this->textViewSecondBaseStatic->setVisible(false);
});
view->addCallback(FormEventType::MouseLeave,
[this](FormsEvent *)
{
// this->textViewSecondBase->setText("");
this->textViewSecondBase->setVisible(false);
this->textViewSecondBaseStatic->setVisible(true);
});
}
textViewSecondBase = form->findControlTyped<Label>("TEXT_BUTTON_SECOND_BASE");
textViewSecondBase->setVisible(false);
Expand Down

0 comments on commit 995e21a

Please sign in to comment.