/* object-collision OBJID_PLAYER against OBJID_EXIT */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
#include <errno.h>
#include "obj-player.h"
#include "obj-exit.h"

int objcoll_PLAYER_EXIT(void *, unsigned int, struct VG_Coll *);


int
objcoll_PLAYER_EXIT(void *vgame, unsigned int instanceid, struct VG_Coll *collb)
{
  struct s_game *sgame = (struct s_game *)vgame;
  struct VG_Object *objp;
  struct sobj_player *objvars_player;
  struct sobj_exit *objvars_exit;
  int retw = VG_COLL_RETURN_CONTINUE;

  if (sgame == NULL) { return retw; }

  if (collb->type != VG_COLL_TYPE_ENTRY) { return retw; }

  /* "moving" instance must be OBJID_PLAYER */
  objp = vg4->object->instance_getobj(instanceid);
  if (strcmp(objp->objid, OBJID_PLAYER) != 0) { return retw; }
  objvars_player = (struct sobj_player *)objp->opriv;

  objp = vg4->object->instance_getobj(collb->instanceid);
  objvars_exit = (struct sobj_exit *)objp->opriv;

  if (objvars_exit->status == SOBJ_EXIT_OPENED) {
    objvars_player->status = SOBJ_PLAYER_DONE;
  }

  return retw;
}
