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

Function Object_Script_Variable4_Set

src/object.c:54–72  ·  view source on GitHub ↗

* Set in a safe way the new value for variable4. * @param o The Object to set variable4 for. * @param index The encoded index to set it to. */

Source from the content-addressed store, hash-verified

52 * @param index The encoded index to set it to.
53 */
54void Object_Script_Variable4_Set(Object *o, uint16 encoded)
55{
56 StructureInfo *si;
57 Structure *s;
58
59 if (o == NULL) return;
60
61 o->script.variables[4] = encoded;
62
63 if (o->flags.s.isUnit) return;
64
65 si = &g_table_structureInfo[o->type];
66 if (!si->o.flags.busyStateIsIncoming) return;
67
68 s = (Structure *)o;
69 if (Structure_GetLinkedUnit(s) != NULL) return;
70
71 Structure_SetState(s, (encoded == 0) ? STRUCTURE_STATE_IDLE : STRUCTURE_STATE_BUSY);
72}
73
74/**
75 * Clear variable4 in a safe (and recursive) way from an object.

Callers 4

Unit_CallUnitByTypeFunction · 0.85

Calls 2

Structure_GetLinkedUnitFunction · 0.85
Structure_SetStateFunction · 0.85

Tested by

no test coverage detected