-
-
Notifications
You must be signed in to change notification settings - Fork 525
/
move.h
92 lines (68 loc) · 3.54 KB
/
move.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*
This file is part of Warzone 2100.
Copyright (C) 1999-2004 Eidos Interactive
Copyright (C) 2005-2011 Warzone 2100 Project
Warzone 2100 is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
Warzone 2100 is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Warzone 2100; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/** @file
* Interface for the unit movement system
*/
#ifndef __INCLUDED_SRC_MOVE_H__
#define __INCLUDED_SRC_MOVE_H__
#include "objectdef.h"
#include "fpath.h"
/* Initialise the movement system */
extern bool moveInitialise(void);
/* Update the base speed for all movement */
extern void moveUpdateBaseSpeed(void);
/* Set a target location for a droid to move to - returns a bool based on if there is a path to the destination (true if there is a path)*/
extern bool moveDroidTo(DROID *psDroid, UDWORD x, UDWORD y, FPATH_MOVETYPE moveType = FMT_MOVE);
/* Set a target location for a droid to move to - returns a bool based on if there is a path to the destination (true if there is a path)*/
// the droid will not join a formation when it gets to the location
extern bool moveDroidToNoFormation(DROID *psDroid, UDWORD x, UDWORD y, FPATH_MOVETYPE moveType = FMT_MOVE);
// move a droid directly to a location (used by vtols only)
extern void moveDroidToDirect(DROID *psDroid, UDWORD x, UDWORD y);
// Get a droid to turn towards a locaton
extern void moveTurnDroid(DROID *psDroid, UDWORD x, UDWORD y);
/* Stop a droid */
extern void moveStopDroid(DROID *psDroid);
/*Stops a droid dead in its tracks - doesn't allow for any little skidding bits*/
extern void moveReallyStopDroid(DROID *psDroid);
/* Get a droid to do a frame's worth of moving */
extern void moveUpdateDroid(DROID *psDroid);
SDWORD moveCalcDroidSpeed(DROID *psDroid);
/* Frame update for the movement of a tracked droid */
extern void moveUpdateTracked(DROID *psDroid);
/* update body and turret to local slope */
extern void updateDroidOrientation(DROID *psDroid);
/* audio callback used to kill movement sounds */
extern bool moveCheckDroidMovingAndVisible( void *psObj );
// set a vtol to be hovering in the air
void moveMakeVtolHover( DROID *psDroid );
/// Get high precision droid position
static inline Position droidGetPrecisePosition(const DROID *psDroid)
{
return Position(psDroid->pos.x * EXTRA_PRECISION + psDroid->sMove.eBitX, psDroid->pos.y * EXTRA_PRECISION + psDroid->sMove.eBitY, 0);
}
/// Set high precision droid position
static inline void droidSetPrecisePosition(DROID *psDroid, Position newPos)
{
// Store extra bits of precision
psDroid->sMove.eBitX = newPos.x & EXTRA_MASK;
psDroid->sMove.eBitY = newPos.y & EXTRA_MASK;
// Drop extra bits of precision. The &~EXTRA_MASK is needed in the case of negative coordinates. Note that signed right-shift of negative numbers is implementation defined, although at least GCC says it does an arithmetic right-shift, which is what's needed.
psDroid->pos.x = (newPos.x & ~EXTRA_MASK) / EXTRA_PRECISION;
psDroid->pos.y = (newPos.y & ~EXTRA_MASK) / EXTRA_PRECISION;
}
const char *moveDescription(MOVE_STATUS status);
#endif // __INCLUDED_SRC_MOVE_H__