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

Function Tools_Index_GetObject

src/tools.c:217–232  ·  view source on GitHub ↗

* Gets the Object corresponding to the given encoded index. * * @param id The encoded index to get the Object of. * @return The Object. */

Source from the content-addressed store, hash-verified

215 * @return The Object.
216 */
217Object *Tools_Index_GetObject(uint16 encoded)
218{
219 uint16 index;
220
221 switch (Tools_Index_GetType(encoded)) {
222 case IT_UNIT:
223 index = Tools_Index_Decode(encoded);
224 return (index < UNIT_INDEX_MAX) ? &Unit_Get_ByIndex(index)->o : NULL;
225
226 case IT_STRUCTURE:
227 index = Tools_Index_Decode(encoded);
228 return (index < STRUCTURE_INDEX_MAX_HARD) ? &Structure_Get_ByIndex(index)->o : NULL;
229
230 default: return NULL;
231 }
232}
233
234/**
235 * Get a random value between 0 and 255.

Callers 4

Calls 4

Tools_Index_GetTypeFunction · 0.85
Tools_Index_DecodeFunction · 0.85
Unit_Get_ByIndexFunction · 0.85
Structure_Get_ByIndexFunction · 0.85

Tested by

no test coverage detected