30typedef enum NPCtype_ {
40typedef struct NPCevtData_ {
47typedef struct NPCmisnData_ {
72static Mission *npc_missions = NULL;
97 if (npc_missions[i].
id == npc->
u.
m.
id)
98 return &npc_missions[i];
139 if (misn->
npc == NULL) {
140 WARN(_(
"Mission '%s' trying to create NPC with no name!"), misn->
data->
name);
144 WARN(_(
"Mission '%s' trying to create NPC with no portrait!"), misn->
data->
name);
148 WARN(_(
"Mission '%s' trying to create NPC with no description!"), misn->
data->
name);
160 npc.
u.
m.
func = strdup(
"accept");
175 npc.
name = strdup( name );
179 npc.
desc = strdup( desc );
181 npc.
u.
m.
func = strdup( func );
189unsigned int npc_add_event(
unsigned int evt,
const char *func,
const char *name,
196 npc.
name = strdup( name );
200 npc.
desc = strdup( desc );
202 npc.
u.
e.
func = strdup( func );
245 if (npc->
u.
e.
id != evt)
267 if (mid != npc->
u.
m.
id)
284 if (npc->
u.
e.
id !=
id )
308 if (npc->
u.
m.
id != mid )
327 const NPC_t *npc1, *npc2;
340 ret = strcmp( npc1->
name, npc2->
name );
345 if (npc1->
id > npc2->
id)
347 else if (npc1->
id < npc2->
id)
369 if (npc_missions == NULL)
380 for (
int i=0; i<nmissions; i++) {
401 WARN(_(
"Mission '%s' was created at the spaceport bar but didn't create any NPC!"), m->
data->
name);
421 if (npc_missions==NULL)
461 WARN(_(
"Freeing NPC of invalid type."));
478 for (
int i=0; i<
array_size( npc_missions ); i++) {
579 WARN(_(
"Unable to find mission '%d' in npc_missions for giver npc '%s'!"), npc->
u.
m.
id, npc->
name);
584 if ((ret==3) || (ret==2) || (ret==-1)) {
621 WARN(_(
"Unable to find mission '%d' in npc_missions for mission npc '%s'!"), npc->
u.
m.
id, npc->
name);
625 lua_pushnumber( naevL, npc->
id );
631 lua_pushnumber( naevL, npc->
id );
636 WARN(_(
"Unknown NPC type!"));
Provides macros to work with dynamic arrays.
#define array_free(ptr_array)
Frees memory allocated and sets array to NULL.
#define array_erase(ptr_array, first, last)
Erases elements in interval [first, last).
static ALWAYS_INLINE int array_size(const void *array)
Returns number of elements in the array.
#define array_grow(ptr_array)
Increases the number of elements by one and returns the last element.
#define array_push_back(ptr_array, element)
Adds a new element at the end of the array.
#define array_create(basic_type)
Creates a new dynamic array of ‘basic_type’.
void bar_regen(void)
Regenerates the bar list.
int mission_accept(Mission *mission)
Small wrapper for misn_run.
Mission ** player_missions
Mission * missions_genList(int *n, int faction, const Spob *pnt, const StarSystem *sys, MissionAvailability loc)
Generates a mission list. This runs create() so won't work with all missions.
void mission_cleanup(Mission *misn)
Cleans up a mission.
Header file with generic functions and naev-specifics.
void event_runStart(unsigned int eventid, const char *func)
Starts running a function, allows programmer to set up arguments.
int event_runFunc(unsigned int eventid, const char *func, int nargs)
Runs a function previously set up with event_runStart.
void misn_runStart(Mission *misn, const char *func)
Sets up the mission to run misn_runFunc.
int misn_runFunc(Mission *misn, const char *func, int nargs)
Runs a mission set up with misn_runStart.
const char * npc_getDesc(int i)
Gets the NPC description.
static int npc_rm(NPC_t *npc)
Removes an npc from the spaceport bar.
void npc_patchMission(Mission *misn)
Patches a new mission bar npc into the bar system.
void npc_generateMissions(void)
Generates the bar missions.
glTexture * npc_getTexture(int i)
Get the texture of an NPC.
static void npc_free(NPC_t *npc)
Frees a single npc.
static unsigned int npc_add(NPC_t *npc)
Adds an NPC to the spaceport bar.
int npc_approach(int i)
Approaches the NPC.
int npc_rm_parentMission(unsigned int mid)
Removes all the npc belonging to a mission.
void npc_clear(void)
Cleans up the spaceport bar NPC.
unsigned int npc_add_event(unsigned int evt, const char *func, const char *name, int priority, glTexture *portrait, const char *desc, glTexture *background)
Adds a event NPC to the mission computer.
static unsigned int npc_add_giver(Mission *misn)
Adds a mission giver NPC to the mission computer.
int npc_getArraySize(void)
Get the size of the npc array.
int npc_rm_parentEvent(unsigned int id)
Removes all the npc belonging to an event.
glTexture * npc_getBackground(int i)
Get the background of an NPC.
static unsigned int npc_array_idgen
unsigned int npc_add_mission(unsigned int mid, const char *func, const char *name, int priority, glTexture *portrait, const char *desc, glTexture *background)
Adds a mission NPC to the mission computer.
int npc_isImportant(int i)
Checks to see if the NPC is important or not.
int npc_rm_mission(unsigned int id, unsigned int mid)
removes a mission NPC.
static int npc_compare(const void *arg1, const void *arg2)
NPC compare function.
int npc_rm_event(unsigned int id, unsigned int evt)
removes an event NPC.
const char * npc_getName(int i)
Get the name of an NPC.
static int npc_approach_giver(NPC_t *npc)
Approaches a mission giver guy.
static Mission * npc_getMisn(const NPC_t *npc)
static NPC_t * npc_arrayGet(unsigned int id)
Gets an NPC by ID.
void npc_sort(void)
Sorts the NPCs.
glTexture * gl_dupTexture(const glTexture *texture)
Duplicates a texture.
glTexture * gl_newImage(const char *path, const unsigned int flags)
Loads an image as a texture.
void gl_freeTexture(glTexture *texture)
Frees a texture.
Represents an active mission.
Minimum needed NPC data for event.
Minimum needed NPC data for mission.
Abstraction for rendering sprite sheets.