[Add] pilot_copy function.
This commit is contained in:
parent
2b8d4ecd82
commit
829d24eb79
@ -142,7 +142,7 @@ void menu_info(void) {
|
||||
0, "txtDPilot", &gl_smallFont, &cDConsole,
|
||||
"Pilot:\n"
|
||||
"Combat\n"
|
||||
" Rating:"
|
||||
" Rating:"
|
||||
"\n"
|
||||
"Ship:\n");
|
||||
|
||||
|
29
src/pilot.c
29
src/pilot.c
@ -748,6 +748,35 @@ unsigned int pilot_create(Ship* ship, char* name, Faction* faction,
|
||||
return dyn->id;
|
||||
}
|
||||
|
||||
// Copy src pilot to dest.
|
||||
void pilot_copy(Pilot* dest, Pilot* src) {
|
||||
memcpy(dest, src, sizeof(Pilot));
|
||||
if(src->name) dest->name = strdup(src->name);
|
||||
|
||||
// Solid.
|
||||
dest->solid = malloc(sizeof(Solid));
|
||||
memcpy(dest->solid, src->solid, sizeof(Solid));
|
||||
|
||||
// Copy outfits.
|
||||
dest->outfits = malloc(sizeof(PilotOutfit)*src->noutfits);
|
||||
memcpy(dest->outfits, src->outfits,
|
||||
sizeof(PilotOutfit)*src->noutfits);
|
||||
dest->secondary = NULL;
|
||||
dest->ammo = NULL;
|
||||
dest->afterburner = NULL;
|
||||
|
||||
// Copy commodities.
|
||||
dest->commodities = malloc(sizeof(PilotCommodity)*src->ncommodities);
|
||||
memcpy(dest->commodities, src->commodities,
|
||||
sizeof(PilotCommodity)*src->ncommodities);
|
||||
|
||||
// Ai is not copied.
|
||||
dest->task = NULL;
|
||||
|
||||
// Will set afterburner and correct stats.
|
||||
pilot_calcStats(dest);
|
||||
}
|
||||
|
||||
// Frees and cleans up a pilot.
|
||||
static void pilot_free(Pilot* p) {
|
||||
if(player == p) player = NULL;
|
||||
|
@ -149,6 +149,8 @@ unsigned int pilot_create(Ship* ship, char* name, Faction* faction,
|
||||
AI_Profile* ai, const double dir, const Vec2* pos,
|
||||
const Vec2* vel, const int flags);
|
||||
|
||||
void pilot_copy(Pilot* dest, Pilot* src);
|
||||
|
||||
// Init/Cleanup.
|
||||
void pilot_destroy(Pilot* p);
|
||||
void pilots_free(void);
|
||||
|
10
src/player.h
10
src/player.h
@ -5,12 +5,12 @@
|
||||
#define PLAYER_TURN_LEFT (1<<0) // Player is turning left.
|
||||
#define PLAYER_TURN_RIGHT (1<<1) // Player is turning right.
|
||||
#define PLAYER_REVERSE (1<<2) // Player is facint opposite vel.
|
||||
#define PLAYER_AFTERBURNER (1<<3) // Player is burning it up.
|
||||
#define PLAYER_DESTROYED (1<<9) // Player goes BOOM!
|
||||
#define PLAYER_AFTERBURNER (1<<3) // Player is burning it up.
|
||||
#define PLAYER_DESTROYED (1<<9) // Player goes BOOM!
|
||||
#define PLAYER_FACE (1<<10) // Player is facing target.
|
||||
#define PLAYER_PRIMARY (1<<11) // Player is shooting primary weapon.
|
||||
#define PLAYER_SECONDARY (1<<12) // Player is shooting secondary weapon.
|
||||
#define PLAYER_LANDACK (1<<13) // Player has permission to land.
|
||||
#define PLAYER_LANDACK (1<<13) // Player has permission to land.
|
||||
|
||||
// Flag functions.
|
||||
#define player_isFlag(f) (player_flags & f)
|
||||
@ -25,7 +25,9 @@ extern int player_credits;
|
||||
extern int combat_crating;
|
||||
|
||||
// Enums.
|
||||
typedef enum RadarShape_ { RADAR_RECT, RADAR_CIRCLE } RadarShape; // For render functions.
|
||||
|
||||
// For render functions.
|
||||
typedef enum RadarShape_ { RADAR_RECT, RADAR_CIRCLE } RadarShape;
|
||||
|
||||
// Creation.
|
||||
void player_new(void);
|
||||
|
Loading…
Reference in New Issue
Block a user