#ifndef MAIN_H_
#define MAIN_H_

#include <vgagames4.h>

#undef VERBOSE

/* include object-IDs */
#include "objid.h"

/* include exported object-functions */
#include "objfn.h"

#define LOOP_TIME 50

#define OBST_SIZE 16
#define GANG_SIZE 24
#define BGMUL_SIZE 7

#define ZUFALL(P0, P1, P2)  vg4->random->get((P0), (P1), (P2))

extern void _my_assert(const char *, int, int);
#define my_assert(condit)  _my_assert(__FILE__, __LINE__, condit)

/* game enumerations */
enum { GAMEPLAY_ERROR = -1, GAMEPLAY_NOOP = 0, GAMEPLAY_DONE, GAMEPLAY_DEAD, GAMEPLAY_MENU, GAMEPLAY_REDO };

/* signal enumeration */
enum { SIGNO_ACTIVE = 1, SIGNO_REINIT };

/* individual settings */ 
struct savedata {
  struct {
    int gamelevel;         /* game level (starting with 0) */
    int gold;              /* gold coins */
    int anzbombs;          /* number of bombs to put at the same time */
    int extralife;         /* whether has extralife */
    int nr_ohard;          /* number of OHARD */
  } dold, dnew;
};


/* private structure of the game */
struct s_game {
  int winw, winh;                /* window's width and height */
  struct savedata svdt;          /* individual settings to save */
  unsigned int coll_tag;         /* collision-tag */

  VG_BOOL level_clear;           /* whether level is clear */
  VG_BOOL suspend;               /* whether suspend f_run()-functions */
  VG_BOOL bg_atonce;             /* whether move background at once to focussed object */
  int a_music;                   /* audio descriptor for music */

  struct {                       /* nodes for hunters */
    struct VG_Hash *hnode;         /* nodes */
    int max_x, max_y;              /* hightest number of nodes: x and y direction */
    struct VG_Nodelink *ndlnk;     /* nodelink for moving */
  } nodes;

  struct {
    unsigned int audio;          /* instance-ID of audio */
    unsigned int bg;             /* instance-ID of background */
    unsigned int player;         /* instance-ID of player */
    unsigned int exit;           /* instance-ID of exit-door */
    unsigned int focus;          /* instance-ID of object to be focused if not 0 */
  } instanceid;

  struct {                       /* keys */
    int k_quit_lalt;               /* part of quit: Left-ALT */
    int k_quit_q;                  /* part of quit: Q */
    int k_sysmenu;                 /* system-menu */
    int k_help;                    /* help */
    int k_pause;                   /* pause */
    int k_left;                    /* go left */
    int k_right;                   /* go right */
    int k_up;                      /* go up */
    int k_down;                    /* go down */
    int k_drop_bomb;               /* drop bomb */
  } kref;
};


/* misc.c */
extern void get_node_near_position(struct s_game *, int, int, char *, size_t);
extern void set_goody_to_osoft(struct s_game *);
extern void create_new_goody(struct s_game *, const char *, int, int);

#endif /* MAIN_H_ */
