DataMuseum.dk

Presents historical artifacts from the history of:

DKUUG/EUUG Conference tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about DKUUG/EUUG Conference tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - metrics - download
Index: T u

⟦84c23d97d⟧ TextFile

    Length: 5647 (0x160f)
    Types: TextFile
    Names: »unit.h«

Derivation

└─⟦b20c6495f⟧ Bits:30007238 EUUGD18: Wien-båndet, efterår 1987
    └─⟦this⟧ »EUUGD18/X/Xconq/unit.h« 

TextFile

/* Copyright (c) 1987, 1988  Stanley T. Shebs, University of Utah. */
/* This program may be used, copied, modified, and redistributed freely */
/* for noncommercial purposes, so long as this notice remains intact. */

/* RCS $Header: unit.h,v 1.1 88/06/21 12:29:48 shebs Exp $ */

/* Definitions about units and their orders. */

#define NOTHING (MAXUTYPES+1)  /* A number guaranteed to be a non-unit. */

/* Unit order types.  Each type has a letter, name, short name, and some */
/* parameter types that guide how the order will be input. */

#define NUMORDERTYPES 8

#define NONE     0
#define AWAKE    1
#define SENTRY   2
#define MOVEDIR  3
#define MOVETO   4
#define EDGE     5
#define FOLLOW   6
#define PATROL   7

#define ORDERNAMES \
  { "None", "Awake", "Sentry", "Dir Move", "Move to", \
    "Follow Edge", "Follow Leader", "Patrol" }

/* Types of arguments that orders can have. */

#define NOARG     0
#define DIR       1
#define POS       2
#define LEADER    3
#define WAYPOINTS 4

#define ORDERARGS \
  { NOARG, NOARG, NOARG, DIR, POS, DIR, LEADER, WAYPOINTS }

#define ORDERARGNAMES \
  { "no args", "no args", "no args", "direction", \
    "destination", "direction", "unit", "waypoints" }

/* Number of points possible in order parameters.  If actual number not */
/* implicit in order type, then will need a count field somewhere. */

#define NUMWPS 2

/* Bit-encoded flags that specify's units behavior when under orders. */

#define ENEMYWAKE     0x01
#define NEUTRALWAKE   0x02
#define SUPPLYWAKE    0x04
#define ATTACKUNIT    0x08
#define SHORTESTPATH  0x10

#define ALLFLAGS      0x1f

#define NORMAL  ALLFLAGS

/* tiny hack structure */

typedef struct a_pt {
    short x, y;
} Pt;

/* Definition of an "order", which is the means by which a unit keeps */
/* track of what it should do.  Needs the encapsulation because orders */
/* show up in both units and in collections of standing orders. */

typedef struct a_order {
    short type;               /* type of order (awake, random, etc) */
    short rept;               /* number to repeat order */
    short flags;              /* bit vector of special flags */
    union {
	short dir;            /* a direction */
	struct a_unit *leader;  /* pointer to a leader unit */
	Pt pt[NUMWPS];        /* small array of coordinates */
    } p;                      /* parameters of an order */
} Order;

/* A standing order is actually an array with an order for each unit type. */
/* The structure is allocated only when a standing order is given. */

typedef struct s_order {
    Order *orders[MAXUTYPES];
} StandingOrder;

/* This structure should be small, because there may be many of them. */
/* On the other hand, changing shorts to chars would entail fiddling with */
/* mapfile code, so beware. */

typedef struct a_unit {
    /* Level 1 detail */
    short type;                /* type (army, ship, etc) */
    char *name;                /* the name, if given */
    short x, y;                /* position of unit on map */
    struct a_side *side;       /* whose side this unit is on */
    /* Level 2 detail */
    short id;                  /* truly unique id number */
    short number;              /* semi-unique id number */
    struct a_side *trueside;   /* whose side this unit is really on */
    short hp;                  /* how much more damage it can take */
    short quality;             /* "veteran-ness" */
    short morale;              /* how happy our guys are */
    short fatigue;             /* how tired they are */
    short product;             /* type of unit this unit is producing */
    short schedule;            /* when the unit will be done */
    short built;               /* how many units of current type made so far */
    struct a_unit *transport;  /* pointer to transporter if any */
    short supply[MAXRTYPES];   /* how much supply we're carrying */
    /* Level 3 detail */
    short group;               /* group to which unit belongs (machine) */
    short goal;                /* personal goal of unit */
    short gx, gy;              /* current goal position */
    short movesleft;           /* how many moves left in this turn */
    short actualmoves;         /* hexes actually covered this turn */
    short lastdir;             /* last direction of move */
    short awake;               /* true if unit temporarily awake */
    Order orders;              /* current orders being carried out */
    StandingOrder *standing;   /* pointer to collection of standing orders */
    /* Never saved */
    struct a_unit *occupant;   /* pointer to first unit being carried */
    struct a_unit *nexthere;   /* pointer to fellow occupant */
    struct a_unit *next;       /* next unit in list of all units */
} Unit;

/* Some convenient macros. */

#define for_all_units(v) for (v = unitlist; v != NULL; v = v->next)

#define for_all_occupants(u1,u2) \
  for (u2 = u1->occupant; u2 != NULL; u2 = u2->nexthere)

#define alive(u) ((u)->hp > 0)

#define cripple(u) ((u)->hp < utypes[(u)->type].crippled)

#define neutral(u) ((u)->side == NULL)

#define producing(u) ((u)->product != NOTHING)

#define busy(u) (producing(u) || (u)->schedule > 0)

#define idled(u) (utypes[(u)->type].maker && !busy(u))

#define mobile(u) (utypes[u].speed > 0)

#define could_occupy(u,t) (could_move(u,t))

/* Unit variables. */

extern Unit *unitlist, *tmpunit;
extern Unit *create_unit(), *read_basic_unit(), *random_start_unit();
extern Unit *find_unit();

extern int numunits, orderargs[];

extern char *ordernames[];
extern char *random_unit_name(), *unit_handle(), *short_unit_handle();
extern char *make_unit_name(), *order_desig();