* Sets the selection on given packed tile. * * @param packed The packed tile to set the selection on. */
| 97 | * @param packed The packed tile to set the selection on. |
| 98 | */ |
| 99 | void Map_SetSelection(uint16 packed) |
| 100 | { |
| 101 | if (g_selectionType == SELECTIONTYPE_TARGET) return; |
| 102 | |
| 103 | if (g_selectionType == SELECTIONTYPE_PLACE) { |
| 104 | g_selectionState = Structure_IsValidBuildLocation(packed, g_structureActiveType); |
| 105 | g_selectionPosition = packed; |
| 106 | return; |
| 107 | } |
| 108 | |
| 109 | if ((packed != 0xFFFF && g_map[packed].overlayTileID != g_veiledTileID) || g_debugScenario) { |
| 110 | Structure *s; |
| 111 | |
| 112 | s = Structure_Get_ByPackedTile(packed); |
| 113 | if (s != NULL) { |
| 114 | const StructureInfo *si; |
| 115 | |
| 116 | si = &g_table_structureInfo[s->o.type]; |
| 117 | if (s->o.houseID == g_playerHouseID && g_selectionType != SELECTIONTYPE_MENTAT) { |
| 118 | GUI_DisplayHint(si->o.hintStringID, si->o.spriteID); |
| 119 | } |
| 120 | |
| 121 | packed = Tile_PackTile(s->o.position); |
| 122 | |
| 123 | Map_SetSelectionSize(si->layout); |
| 124 | |
| 125 | Structure_UpdateMap(s); |
| 126 | } else { |
| 127 | Map_SetSelectionSize(STRUCTURE_LAYOUT_1x1); |
| 128 | } |
| 129 | |
| 130 | if (g_selectionType != SELECTIONTYPE_TARGET) { |
| 131 | Unit *u; |
| 132 | |
| 133 | u = Unit_Get_ByPackedTile(packed); |
| 134 | if (u != NULL) { |
| 135 | if (u->o.type != UNIT_CARRYALL) { |
| 136 | Unit_Select(u); |
| 137 | } |
| 138 | } else { |
| 139 | if (g_unitSelected != NULL) { |
| 140 | Unit_Select(NULL); |
| 141 | } |
| 142 | } |
| 143 | } |
| 144 | g_selectionPosition = packed; |
| 145 | return; |
| 146 | } |
| 147 | |
| 148 | Map_SetSelectionSize(STRUCTURE_LAYOUT_1x1); |
| 149 | g_selectionPosition = packed; |
| 150 | return; |
| 151 | } |
| 152 | |
| 153 | /** |
| 154 | * Sets the selection size for the given layout. |
no test coverage detected