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

Function Script_Unit_TransportDeliver

src/script/unit.c:123–214  ·  view source on GitHub ↗

* Delivery of transport, either to structure or to a tile. * * Stack: *none*. * * @param script The script engine to operate on. * @return One if delivered, zero otherwise.. */

Source from the content-addressed store, hash-verified

121 * @return One if delivered, zero otherwise..
122 */
123uint16 Script_Unit_TransportDeliver(ScriptEngine *script)
124{
125 Unit *u;
126 Unit *u2;
127
128 VARIABLE_NOT_USED(script);
129
130 u = g_scriptCurrentUnit;
131
132 if (u->o.linkedID == 0xFF) return 0;
133 if (Tools_Index_GetType(u->targetMove) == IT_UNIT) return 0;
134
135 if (Tools_Index_GetType(u->targetMove) == IT_STRUCTURE) {
136 const StructureInfo *si;
137 Structure *s;
138
139 s = Tools_Index_GetStructure(u->targetMove);
140 si = &g_table_structureInfo[s->o.type];
141
142 if (s->o.type == STRUCTURE_STARPORT) {
143 uint16 ret = 0;
144
145 if (s->state == STRUCTURE_STATE_BUSY) {
146 s->o.linkedID = u->o.linkedID;
147 u->o.linkedID = 0xFF;
148 u->o.flags.s.inTransport = false;
149 u->amount = 0;
150
151 Unit_UpdateMap(2, u);
152
153 Voice_PlayAtTile(24, u->o.position);
154
155 Structure_SetState(s, STRUCTURE_STATE_READY);
156
157 ret = 1;
158 }
159
160 Object_Script_Variable4_Clear(&u->o);
161 u->targetMove = 0;
162
163 return ret;
164 }
165
166 if ((s->state == STRUCTURE_STATE_IDLE || (si->o.flags.busyStateIsIncoming && s->state == STRUCTURE_STATE_BUSY)) && s->o.linkedID == 0xFF) {
167 Voice_PlayAtTile(24, u->o.position);
168
169 Unit_EnterStructure(Unit_Get_ByIndex(u->o.linkedID), s);
170
171 Object_Script_Variable4_Clear(&u->o);
172 u->targetMove = 0;
173
174 u->o.linkedID = 0xFF;
175 u->o.flags.s.inTransport = false;
176 u->amount = 0;
177
178 Unit_UpdateMap(2, u);
179
180 return 1;

Callers

nothing calls this directly

Calls 13

Tools_Index_GetTypeFunction · 0.85
Tools_Index_GetStructureFunction · 0.85
Unit_UpdateMapFunction · 0.85
Voice_PlayAtTileFunction · 0.85
Structure_SetStateFunction · 0.85
Unit_EnterStructureFunction · 0.85
Unit_Get_ByIndexFunction · 0.85
Map_IsValidPositionFunction · 0.85
Tile_CenterFunction · 0.85
Unit_SetPositionFunction · 0.85
Unit_SetOrientationFunction · 0.85

Tested by

no test coverage detected