* Gets the Object corresponding to the given encoded index. * * @param id The encoded index to get the Object of. * @return The Object. */
| 215 | * @return The Object. |
| 216 | */ |
| 217 | Object *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. |
no test coverage detected