[Change] pilot_free uses memmove.

This commit is contained in:
Allanis 2013-07-06 16:42:28 +01:00
parent 30b6dfed77
commit ab277eabb4

View File

@ -1032,17 +1032,18 @@ void pilot_free(Pilot* p) {
/* Destroy pilot from stack. */ /* Destroy pilot from stack. */
void pilot_destroy(Pilot* p) { void pilot_destroy(Pilot* p) {
int i; int i;
/* Find the pilot. */
for(i = 0; i < pilot_nstack; i++) for(i = 0; i < pilot_nstack; i++)
if(pilot_stack[i] == p) if(pilot_stack[i] == p)
break; break;
/* Pilot is eliminated. */
pilot_free(p);
pilot_nstack--; pilot_nstack--;
while(i < pilot_nstack) { /* Copy other pilots down. */
pilot_stack[i] = pilot_stack[i+1]; memmove(&pilot_stack[i], &pilot_stack[i+1], (pilot_nstack-i)*sizeof(Pilot*));
i++;
}
pilot_free(p);
} }
/* Free the prisoned pilot! */ /* Free the prisoned pilot! */