/* NewDustObj.c         */
/* R Griffin 1997       */

#include "Popcorn:Popcorn.h"

struct dust_object *Popcorn_NewDustObject(struct dust_object_table *table,
  int i) {
  struct dust_object *dust;
  /* object is created if slot is empty or i flag is set */
  dust = &(table->object[table->next_slot]);
  if (dust->object_id == 0 || i == TRUE) {
    /* create object and increment counter */
    if (++table->next_slot == table->max_objects) table->next_slot = 0;
    return dust;
  }
  return NULL;
}
