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

Function Object_Script_Variable4_Link

src/object.c:23–47  ·  view source on GitHub ↗

* Link two variable4 values to eachother, and clean up existing values if * needed. * @param encodedFrom From where the link goes. * @param encodedTo To where the link goes. */

Source from the content-addressed store, hash-verified

21 * @param encodedTo To where the link goes.
22 */
23void Object_Script_Variable4_Link(uint16 encodedFrom, uint16 encodedTo)
24{
25 Object *objectFrom;
26 Object *objectTo;
27
28 if (!Tools_Index_IsValid(encodedFrom)) return;
29 if (!Tools_Index_IsValid(encodedTo)) return;
30
31 objectFrom = Tools_Index_GetObject(encodedFrom);
32 objectTo = Tools_Index_GetObject(encodedTo);
33
34 if (objectFrom == NULL) return;
35 if (objectTo == NULL) return;
36
37 if (objectFrom->script.variables[4] != objectTo->script.variables[4]) {
38 Object_Script_Variable4_Clear(objectFrom);
39 Object_Script_Variable4_Clear(objectTo);
40 }
41 if (objectFrom->script.variables[4] != 0) return;
42
43 Object_Script_Variable4_Set(objectFrom, encodedTo);
44 Object_Script_Variable4_Set(objectTo, encodedFrom);
45
46 return;
47}
48
49/**
50 * Set in a safe way the new value for variable4.

Callers 4

Unit_SetDestinationFunction · 0.85
Script_Unit_PickupFunction · 0.85

Calls 4

Tools_Index_IsValidFunction · 0.85
Tools_Index_GetObjectFunction · 0.85

Tested by

no test coverage detected