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

Function Structure_SetRepairingState

src/structure.c:1735–1773  ·  view source on GitHub ↗

* Sets or toggle the repairing state of the given Structure. * * @param s The Structure. * @param value The repairing 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

1733 * @return True if and only if the state changed.
1734 */
1735bool Structure_SetRepairingState(Structure *s, int8 state, Widget *w)
1736{
1737 bool ret = false;
1738
1739 if (s == NULL) return false;
1740
1741 /* ENHANCEMENT -- If a structure gets damaged during upgrading, pressing the "Upgrading" button silently starts the repair of the structure, and doesn't cancel upgrading. */
1742 if (g_dune2_enhanced && s->o.flags.s.upgrading) return false;
1743
1744 if (!s->o.flags.s.allocated) state = 0;
1745
1746 if (state == -1) state = s->o.flags.s.repairing ? 0 : 1;
1747
1748 if (state == 0 && s->o.flags.s.repairing) {
1749 if (s->o.houseID == g_playerHouseID) {
1750 GUI_DisplayText(String_Get_ByIndex(STR_REPAIRING_STOPS), 2);
1751 }
1752
1753 s->o.flags.s.repairing = false;
1754 s->o.flags.s.onHold = false;
1755
1756 GUI_Widget_MakeNormal(w, false);
1757
1758 ret = true;
1759 }
1760
1761 if (state == 0 || s->o.flags.s.repairing || s->o.hitpoints == g_table_structureInfo[s->o.type].o.hitpoints) return ret;
1762
1763 if (s->o.houseID == g_playerHouseID) {
1764 GUI_DisplayText(String_Get_ByIndex(STR_REPAIRING_STARTS), 2);
1765 }
1766
1767 s->o.flags.s.onHold = true;
1768 s->o.flags.s.repairing = true;
1769
1770 GUI_Widget_MakeSelected(w, false);
1771
1772 return true;
1773}
1774
1775/**
1776 * Update the map with the right data for this structure.

Callers 3

GameLoop_StructureFunction · 0.85
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