* Untarget the given Structure. * * @param unit The Structure to untarget. */
| 1209 | * @param unit The Structure to untarget. |
| 1210 | */ |
| 1211 | void Structure_UntargetMe(Structure *s) |
| 1212 | { |
| 1213 | PoolFindStruct find; |
| 1214 | uint16 encoded = Tools_Index_Encode(s->o.index, IT_STRUCTURE); |
| 1215 | |
| 1216 | Object_Script_Variable4_Clear(&s->o); |
| 1217 | |
| 1218 | find.houseID = HOUSE_INVALID; |
| 1219 | find.index = 0xFFFF; |
| 1220 | find.type = 0xFFFF; |
| 1221 | |
| 1222 | while (true) { |
| 1223 | Unit *u; |
| 1224 | |
| 1225 | u = Unit_Find(&find); |
| 1226 | if (u == NULL) break; |
| 1227 | |
| 1228 | if (u->targetMove == encoded) u->targetMove = 0; |
| 1229 | if (u->targetAttack == encoded) u->targetAttack = 0; |
| 1230 | if (u->o.script.variables[4] == encoded) Object_Script_Variable4_Clear(&u->o); |
| 1231 | } |
| 1232 | |
| 1233 | find.houseID = HOUSE_INVALID; |
| 1234 | find.index = 0xFFFF; |
| 1235 | find.type = 0xFFFF; |
| 1236 | |
| 1237 | while (true) { |
| 1238 | Team *t; |
| 1239 | |
| 1240 | t = Team_Find(&find); |
| 1241 | if (t == NULL) break; |
| 1242 | |
| 1243 | if (t->target == encoded) t->target = 0; |
| 1244 | } |
| 1245 | } |
| 1246 | |
| 1247 | /** |
| 1248 | * Find a free spot for units next to a structure. |
no test coverage detected