* Set the new destination of the unit. * * Stack: 1 - An encoded index where to move to. * * @param script The script engine to operate on. * @return The value 0. Always. */
| 794 | * @return The value 0. Always. |
| 795 | */ |
| 796 | uint16 Script_Unit_SetDestination(ScriptEngine *script) |
| 797 | { |
| 798 | Unit *u; |
| 799 | uint16 encoded; |
| 800 | |
| 801 | u = g_scriptCurrentUnit; |
| 802 | encoded = STACK_PEEK(1); |
| 803 | |
| 804 | if (encoded == 0 || !Tools_Index_IsValid(encoded)) { |
| 805 | u->targetMove = 0; |
| 806 | return 0; |
| 807 | } |
| 808 | |
| 809 | if (u->o.type == UNIT_HARVESTER) { |
| 810 | Structure *s; |
| 811 | |
| 812 | s = Tools_Index_GetStructure(encoded); |
| 813 | if (s == NULL) { |
| 814 | u->targetMove = encoded; |
| 815 | u->route[0] = 0xFF; |
| 816 | return 0; |
| 817 | } |
| 818 | |
| 819 | if (s->o.script.variables[4] != 0) return 0; |
| 820 | } |
| 821 | |
| 822 | Unit_SetDestination(u, encoded); |
| 823 | return 0; |
| 824 | } |
| 825 | |
| 826 | /** |
| 827 | * Set a new target, and rotate towards him if needed. |
nothing calls this directly
no test coverage detected