MCPcopy Create free account
hub / github.com/OpenDUNE/OpenDUNE / Structure_SetUpgradingState

Function Structure_SetUpgradingState

src/structure.c:1691–1725  ·  view source on GitHub ↗

* Sets or toggle the upgrading state of the given Structure. * * @param s The Structure. * @param value The upgrading state, -1 to toggle. * @param w The widget. * @return True if and only if the state changed. */

Source from the content-addressed store, hash-verified

1689 * @return True if and only if the state changed.
1690 */
1691bool Structure_SetUpgradingState(Structure *s, int8 state, Widget *w)
1692{
1693 bool ret = false;
1694
1695 if (s == NULL) return false;
1696
1697 if (state == -1) state = s->o.flags.s.upgrading ? 0 : 1;
1698
1699 if (state == 0 && s->o.flags.s.upgrading) {
1700 if (s->o.houseID == g_playerHouseID) {
1701 GUI_DisplayText(String_Get_ByIndex(STR_UPGRADING_STOPS), 2);
1702 }
1703
1704 s->o.flags.s.upgrading = false;
1705 s->o.flags.s.onHold = false;
1706
1707 GUI_Widget_MakeNormal(w, false);
1708
1709 ret = true;
1710 }
1711
1712 if (state == 0 || s->o.flags.s.upgrading || s->upgradeTimeLeft == 0) return ret;
1713
1714 if (s->o.houseID == g_playerHouseID) {
1715 GUI_DisplayText(String_Get_ByIndex(STR_UPGRADING_STARTS), 2);
1716 }
1717
1718 s->o.flags.s.onHold = true;
1719 s->o.flags.s.repairing = false;
1720 s->o.flags.s.upgrading = true;
1721
1722 GUI_Widget_MakeSelected(w, false);
1723
1724 return true;
1725}
1726
1727/**
1728 * Sets or toggle the repairing state of the given Structure.

Callers 2

Structure_BuildObjectFunction · 0.85

Calls 4

GUI_DisplayTextFunction · 0.85
String_Get_ByIndexFunction · 0.85
GUI_Widget_MakeNormalFunction · 0.85
GUI_Widget_MakeSelectedFunction · 0.85

Tested by

no test coverage detected