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

Function Structure_Free

src/pool/structure.c:180–202  ·  view source on GitHub ↗

* Free a Structure. * * @param address The address of the Structure to free. */

Source from the content-addressed store, hash-verified

178 * @param address The address of the Structure to free.
179 */
180void 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}

Callers 6

GameLoop_StructureFunction · 0.85
Structure_CreateFunction · 0.85
Structure_PlaceFunction · 0.85
Structure_RemoveFunction · 0.85
Structure_CancelBuildFunction · 0.85
GUI_Widget_Cancel_ClickFunction · 0.85

Calls 1

Script_ResetFunction · 0.85

Tested by

no test coverage detected