direction.h
author Darkvater
Sat, 12 Aug 2006 12:22:38 +0000
branch0.4
changeset 10074 cae7dc5c5dfe
parent 10032 fcf09abbde96
permissions -rw-r--r--
(svn r5861) - Backport from trunk (r5839):
A ship in a depot must be stopped before allowed to be cloned (copied ship.h from trunk).
10032
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
     1
/* $Id$ */
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
     2
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
     3
#ifndef DIRECTION_H
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
     4
#define DIRECTION_H
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
     5
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
     6
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
     7
/* the 2 axis */
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
     8
typedef enum Axis {
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
     9
	AXIS_X = 0,
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
    10
	AXIS_Y = 1,
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
    11
	AXIS_END
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
    12
} Axis;
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
    13
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
    14
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
    15
static inline Axis DiagDirToAxis(uint d)
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
    16
{
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
    17
	return (Axis)(d & 1);
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
    18
}
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
    19
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
    20
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
    21
/*
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
    22
 * Converts an Axis to a DiagDirection
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
    23
 * Points always in the positive direction, i.e. S[EW]
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
    24
 */
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
    25
static inline uint AxisToDiagDir(Axis a)
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
    26
{
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
    27
	return (uint)(2 - a);
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
    28
}
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
    29
fcf09abbde96 (svn r5115) Move helper functions to where they belong
tron
parents:
diff changeset
    30
#endif