#include "Popcorn:h.Popcorn"

struct game_object *Popcorn_NewObject(struct object_table* table) {
  register int check_object;

/*   if (table->header != TABLE_HEADER_WORD) i.e. bad table reference */
/*     system("Debug"); */

  if (table->next_free < table->max_objects) {
    table->next_free++;
    return(&(table->object[(table->next_free)-1]));
  }

  for (check_object = 0; check_object < table->max_objects; check_object++)
    if (table->object[check_object].object_id == 0)
      return(&table->object[check_object]);

  return NULL;
}
