* Unknown function 0C5A. * * Stack: *none* * * @param script The script engine to operate on. * @return unknown. */
| 235 | * @return unknown. |
| 236 | */ |
| 237 | uint16 Script_Structure_Unknown0C5A(ScriptEngine *script) |
| 238 | { |
| 239 | tile32 tile; |
| 240 | Structure *s; |
| 241 | Unit *u; |
| 242 | uint16 position; |
| 243 | |
| 244 | VARIABLE_NOT_USED(script); |
| 245 | |
| 246 | s = g_scriptCurrentStructure; |
| 247 | |
| 248 | if (s->o.linkedID == 0xFF) return 0; |
| 249 | |
| 250 | u = Unit_Get_ByIndex(s->o.linkedID); |
| 251 | |
| 252 | if (g_table_unitInfo[u->o.type].movementType == MOVEMENT_WINGER && Unit_SetPosition(u, s->o.position)) { |
| 253 | s->o.linkedID = u->o.linkedID; |
| 254 | u->o.linkedID = 0xFF; |
| 255 | |
| 256 | if (s->o.linkedID == 0xFF) Structure_SetState(s, STRUCTURE_STATE_IDLE); |
| 257 | Object_Script_Variable4_Clear(&s->o); |
| 258 | |
| 259 | if (s->o.houseID == g_playerHouseID) Sound_Output_Feedback(g_playerHouseID + 49); |
| 260 | |
| 261 | return 1; |
| 262 | } |
| 263 | |
| 264 | position = Structure_FindFreePosition(s, u->o.type == UNIT_HARVESTER); |
| 265 | if (position == 0) return 0; |
| 266 | |
| 267 | u->o.seenByHouses |= s->o.seenByHouses; |
| 268 | |
| 269 | tile = Tile_Center(Tile_UnpackTile(position)); |
| 270 | |
| 271 | if (!Unit_SetPosition(u, tile)) return 0; |
| 272 | |
| 273 | s->o.linkedID = u->o.linkedID; |
| 274 | u->o.linkedID = 0xFF; |
| 275 | |
| 276 | Unit_SetOrientation(u, Tile_GetDirection(s->o.position, u->o.position) & 0xE0, true, 0); |
| 277 | Unit_SetOrientation(u, u->orientation[0].current, true, 1); |
| 278 | |
| 279 | if (u->o.houseID == g_playerHouseID && u->o.type == UNIT_HARVESTER) { |
| 280 | GUI_DisplayHint(STR_SEARCH_FOR_SPICE_FIELDS_TO_HARVEST, 0x6A); |
| 281 | } |
| 282 | |
| 283 | if (s->o.linkedID == 0xFF) Structure_SetState(s, STRUCTURE_STATE_IDLE); |
| 284 | Object_Script_Variable4_Clear(&s->o); |
| 285 | |
| 286 | if (s->o.houseID != g_playerHouseID) return 1; |
| 287 | if (s->o.type == STRUCTURE_REPAIR) return 1; |
| 288 | |
| 289 | Sound_Output_Feedback(g_playerHouseID + ((u->o.type == UNIT_HARVESTER) ? 68 : 30)); |
| 290 | |
| 291 | return 1; |
| 292 | } |
| 293 | |
| 294 | /** |
nothing calls this directly
no test coverage detected