* Free a Structure. * * @param address The address of the Structure to free. */
| 178 | * @param address The address of the Structure to free. |
| 179 | */ |
| 180 | void Structure_Free(Structure *s) |
| 181 | { |
| 182 | int i; |
| 183 | |
| 184 | memset(&s->o.flags, 0, sizeof(s->o.flags)); |
| 185 | |
| 186 | Script_Reset(&s->o.script, g_scriptStructure); |
| 187 | |
| 188 | if (s->o.type == STRUCTURE_SLAB_1x1 || s->o.type == STRUCTURE_SLAB_2x2 || s->o.type == STRUCTURE_WALL) return; |
| 189 | |
| 190 | /* Walk the array to find the Structure we are removing */ |
| 191 | assert(g_structureFindCount <= STRUCTURE_INDEX_MAX_SOFT); |
| 192 | for (i = 0; i < g_structureFindCount; i++) { |
| 193 | if (g_structureFindArray[i] == s) break; |
| 194 | } |
| 195 | assert(i < g_structureFindCount); /* We should always find an entry */ |
| 196 | |
| 197 | g_structureFindCount--; |
| 198 | |
| 199 | /* If needed, close the gap */ |
| 200 | if (i == g_structureFindCount) return; |
| 201 | memmove(&g_structureFindArray[i], &g_structureFindArray[i + 1], (g_structureFindCount - i) * sizeof(g_structureFindArray[0])); |
| 202 | } |
no test coverage detected