[Change] Some more clean up.
This commit is contained in:
parent
b6ede4eb01
commit
da58e41da9
36
src/pilot.c
36
src/pilot.c
@ -1369,7 +1369,7 @@ void pilot_addHook(Pilot* pilot, int type, int hook) {
|
||||
*/
|
||||
void pilot_init(Pilot* pilot, Ship* ship, char* name, int faction,
|
||||
char* ai, const double dir, const Vec2* pos,
|
||||
const Vec2* vel, const int flags) {
|
||||
const Vec2* vel, const unsigned int flags) {
|
||||
|
||||
ShipOutfit* so;
|
||||
|
||||
@ -1432,6 +1432,10 @@ void pilot_init(Pilot* pilot, Ship* ship, char* name, int faction,
|
||||
pilot->think = ai_think;
|
||||
pilot->render = pilot_render;
|
||||
}
|
||||
/* Set enter hyperspace flag if needed. */
|
||||
if(flags & PILOT_HYP_END)
|
||||
pilot_setFlag(pilot, PILOT_HYP_END);
|
||||
|
||||
/* All update the same way. */
|
||||
pilot->update = pilot_update;
|
||||
|
||||
@ -1462,7 +1466,7 @@ void pilot_init(Pilot* pilot, Ship* ship, char* name, int faction,
|
||||
*/
|
||||
unsigned int pilot_create(Ship* ship, char* name, int faction,
|
||||
char* ai, const double dir, const Vec2* pos,
|
||||
const Vec2* vel, const int flags) {
|
||||
const Vec2* vel, const unsigned int flags) {
|
||||
|
||||
Pilot* dyn;
|
||||
|
||||
@ -1499,7 +1503,7 @@ unsigned int pilot_create(Ship* ship, char* name, int faction,
|
||||
* @return Pointer to the new pilot (not added to stack).
|
||||
*/
|
||||
Pilot* pilot_createEmpty(Ship* ship, char* name,
|
||||
int faction, char* ai, const int flags) {
|
||||
int faction, char* ai, const unsigned int flags) {
|
||||
|
||||
Pilot* dyn;
|
||||
dyn = MALLOC_L(Pilot);
|
||||
@ -1650,19 +1654,29 @@ void pilots_cleanAll(void) {
|
||||
*/
|
||||
void pilots_update(double dt) {
|
||||
int i;
|
||||
Pilot* p;
|
||||
|
||||
for(i = 0; i < pilot_nstack; i++) {
|
||||
if(pilot_stack[i]->think && !pilot_isDisabled(pilot_stack[i])) {
|
||||
p = pilot_stack[i];
|
||||
|
||||
/* See if should think. */
|
||||
if(p->think && !pilot_isDisabled(p)) {
|
||||
/* Hyperspace gets special treatment. */
|
||||
if(pilot_isFlag(pilot_stack[i], PILOT_HYP_PREP))
|
||||
pilot_hyperspace(pilot_stack[i]);
|
||||
if(pilot_isFlag(p, PILOT_HYP_PREP))
|
||||
pilot_hyperspace(p);
|
||||
/* Entering hyperspace. */
|
||||
else if(pilot_isFlag(p, PILOT_HYP_END)) {
|
||||
if(VMOD(p->solid->vel) < 2*p->speed)
|
||||
pilot_rmFlag(p, PILOT_HYP_END);
|
||||
}
|
||||
else
|
||||
pilot_stack[i]->think(pilot_stack[i]);
|
||||
p->think(p);
|
||||
}
|
||||
if(pilot_stack[i]->update) {
|
||||
if(pilot_isFlag(pilot_stack[i], PILOT_DELETE))
|
||||
pilot_destroy(pilot_stack[i]);
|
||||
if(p->update) { /* Update. */
|
||||
if(pilot_isFlag(p, PILOT_DELETE))
|
||||
pilot_destroy(p);
|
||||
else
|
||||
pilot_stack[i]->update(pilot_stack[i], dt);
|
||||
p->update(p, dt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
11
src/pilot.h
11
src/pilot.h
@ -53,8 +53,9 @@
|
||||
#define PILOT_HYP_PREP (1<<15) /**< Pilot is getting ready for hyperspace. */
|
||||
#define PILOT_HYP_BEGIN (1<<16) /**< Pilot is starting engines. */
|
||||
#define PILOT_HYPERSPACE (1<<17) /**< Pilot is in hyperspace. */
|
||||
#define PILOT_BOARDED (1<<18) /**< Pilot has been boarded already! */
|
||||
#define PILOT_BRIBED (1<<19) /**< Pilot has been bribed already. */
|
||||
#define PILOT_HYP_END (1<<18) /**< Pilot is exiting hyperspace. */
|
||||
#define PILOT_BOARDED (1<<20) /**< Pilot has been boarded already! */
|
||||
#define PILOT_BRIBED (1<<21) /**< Pilot has been bribed already. */
|
||||
#define PILOT_DISABLED (1<<26) /**< Pilot is disabled. */
|
||||
#define PILOT_DEAD (1<<27) /**< Pilot is on it's death bed. */
|
||||
#define PILOT_DEATH_SOUND (1<<28) /**< Pilot just did death explosion. */
|
||||
@ -269,14 +270,14 @@ int pilot_rmMissionCargo(Pilot* pilot, unsigned int cargo_id, int jettison);
|
||||
/* Creation. */
|
||||
void pilot_init(Pilot* dest, Ship* ship, char* name, int faction,
|
||||
char* ai, const double dir, const Vec2* pos,
|
||||
const Vec2* vel, const int flags);
|
||||
const Vec2* vel, const unsigned int flags);
|
||||
|
||||
unsigned int pilot_create(Ship* ship, char* name, int faction,
|
||||
char* ai, const double dir, const Vec2* pos,
|
||||
const Vec2* vel, const int flags);
|
||||
const Vec2* vel, const unsigned int flags);
|
||||
|
||||
Pilot* pilot_createEmpty(Ship* ship, char* name,
|
||||
int faction, char* ai, const int flags);
|
||||
int faction, char* ai, const unsigned int flags);
|
||||
|
||||
Pilot* pilot_copy(Pilot* src);
|
||||
|
||||
|
@ -457,6 +457,7 @@ static void space_addFleet(Fleet* fleet, int init) {
|
||||
FleetPilot* plt;
|
||||
Planet* planet;
|
||||
int i, c;
|
||||
unsigned int flags;
|
||||
double a, d;
|
||||
Vec2 vv, vp, vn;
|
||||
|
||||
@ -515,10 +516,13 @@ static void space_addFleet(Fleet* fleet, int init) {
|
||||
vect_cadd(&vp, RNG(75, 150) * (RNG(0,1) ? 1 : -1),
|
||||
RNG(75, 150) * (RNG(0,1) ? 1 : -1));
|
||||
a = vect_angle(&vp, &vn);
|
||||
flags = 0;
|
||||
|
||||
/* Entering via hyperspace. */
|
||||
if(c == 0)
|
||||
if(c == 0) {
|
||||
vect_pset(&vv, HYPERSPACE_VEL, a);
|
||||
flags |= PILOT_HYP_END;
|
||||
}
|
||||
/* Starting out landed. */
|
||||
else if(c == 1)
|
||||
vectnull(&vv);
|
||||
@ -534,7 +538,7 @@ static void space_addFleet(Fleet* fleet, int init) {
|
||||
a,
|
||||
&vp,
|
||||
&vv,
|
||||
0);
|
||||
flags);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user