naev 0.10.4
Data Structures | Enumerations | Functions | Variables
npc.c File Reference

Handles NPC stuff. More...

#include "npc.h"
#include "array.h"
#include "dialogue.h"
#include "event.h"
#include "land.h"
#include "log.h"
#include "nlua_evt.h"
#include "nstring.h"
#include "opengl.h"
#include "ndata.h"

Go to the source code of this file.

Data Structures

struct  NPCevtData
 Minimum needed NPC data for event. More...
 
struct  NPCmisnData
 Minimum needed NPC data for mission. More...
 
struct  NPC_t
 The bar NPC. More...
 

Enumerations

enum  NPCtype { NPC_TYPE_NULL , NPC_TYPE_GIVER , NPC_TYPE_MISSION , NPC_TYPE_EVENT }
 NPC types. More...
 

Functions

static unsigned int npc_add (NPC_t *npc)
 Adds an NPC to the spaceport bar. More...
 
static int npc_rm (NPC_t *npc)
 Removes an npc from the spaceport bar. More...
 
static NPC_tnpc_arrayGet (unsigned int id)
 Gets an NPC by ID. More...
 
static void npc_free (NPC_t *npc)
 Frees a single npc. More...
 
static Missionnpc_getMisn (const NPC_t *npc)
 
static unsigned int npc_add_giver (Mission *misn)
 Adds a mission giver NPC to the mission computer. More...
 
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. More...
 
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. More...
 
int npc_rm_event (unsigned int id, unsigned int evt)
 removes an event NPC. More...
 
int npc_rm_mission (unsigned int id, unsigned int mid)
 removes a mission NPC. More...
 
int npc_rm_parentEvent (unsigned int id)
 Removes all the npc belonging to an event. More...
 
int npc_rm_parentMission (unsigned int mid)
 Removes all the npc belonging to a mission. More...
 
static int npc_compare (const void *arg1, const void *arg2)
 NPC compare function. More...
 
void npc_sort (void)
 Sorts the NPCs. More...
 
void npc_generateMissions (void)
 Generates the bar missions. More...
 
void npc_patchMission (Mission *misn)
 Patches a new mission bar npc into the bar system. More...
 
void npc_clear (void)
 Cleans up the spaceport bar NPC. More...
 
int npc_getArraySize (void)
 Get the size of the npc array. More...
 
const char * npc_getName (int i)
 Get the name of an NPC. More...
 
glTexturenpc_getBackground (int i)
 Get the background of an NPC. More...
 
glTexturenpc_getTexture (int i)
 Get the texture of an NPC. More...
 
const char * npc_getDesc (int i)
 Gets the NPC description. More...
 
int npc_isImportant (int i)
 Checks to see if the NPC is important or not. More...
 
static int npc_approach_giver (NPC_t *npc)
 Approaches a mission giver guy. More...
 
int npc_approach (int i)
 Approaches the NPC. More...
 

Variables

static unsigned int npc_array_idgen = 0
 
static NPC_tnpc_array = NULL
 
static Missionnpc_missions = NULL
 

Detailed Description

Handles NPC stuff.

Definition in file npc.c.

Enumeration Type Documentation

◆ NPCtype

enum NPCtype

NPC types.

Enumerator
NPC_TYPE_NULL 

Inexistent NPC.

NPC_TYPE_GIVER 

Mission giver NPC.

NPC_TYPE_MISSION 

NPC generated by a mission.

NPC_TYPE_EVENT 

NPC generated by an event.

Definition at line 30 of file npc.c.

Function Documentation

◆ npc_add()

static unsigned int npc_add ( NPC_t npc)
static

Adds an NPC to the spaceport bar.

Definition at line 106 of file npc.c.

◆ npc_add_event()

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.

Definition at line 189 of file npc.c.

◆ npc_add_giver()

static unsigned int npc_add_giver ( Mission misn)
static

Adds a mission giver NPC to the mission computer.

Definition at line 134 of file npc.c.

◆ npc_add_mission()

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.

Definition at line 168 of file npc.c.

◆ npc_approach()

int npc_approach ( int  i)

Approaches the NPC.

Parameters
iIndex of the NPC to approach.

Definition at line 601 of file npc.c.

◆ npc_approach_giver()

static int npc_approach_giver ( NPC_t npc)
static

Approaches a mission giver guy.

Returns 1 on destroyed, 0 on not destroyed.

Definition at line 570 of file npc.c.

◆ npc_arrayGet()

static NPC_t * npc_arrayGet ( unsigned int  id)
static

Gets an NPC by ID.

Definition at line 222 of file npc.c.

◆ npc_clear()

void npc_clear ( void  )

Cleans up the spaceport bar NPC.

Definition at line 469 of file npc.c.

◆ npc_compare()

static int npc_compare ( const void *  arg1,
const void *  arg2 
)
static

NPC compare function.

Definition at line 325 of file npc.c.

◆ npc_free()

static void npc_free ( NPC_t npc)
static

Frees a single npc.

Definition at line 438 of file npc.c.

◆ npc_generateMissions()

void npc_generateMissions ( void  )

Generates the bar missions.

Definition at line 364 of file npc.c.

◆ npc_getArraySize()

int npc_getArraySize ( void  )

Get the size of the npc array.

Definition at line 495 of file npc.c.

◆ npc_getBackground()

glTexture * npc_getBackground ( int  i)

Get the background of an NPC.

Definition at line 515 of file npc.c.

◆ npc_getDesc()

const char * npc_getDesc ( int  i)

Gets the NPC description.

Definition at line 542 of file npc.c.

◆ npc_getMisn()

static Mission * npc_getMisn ( const NPC_t npc)
static

Gets the mission associated with an NPC.

Definition at line 88 of file npc.c.

◆ npc_getName()

const char * npc_getName ( int  i)

Get the name of an NPC.

Definition at line 503 of file npc.c.

◆ npc_getTexture()

glTexture * npc_getTexture ( int  i)

Get the texture of an NPC.

Definition at line 530 of file npc.c.

◆ npc_isImportant()

int npc_isImportant ( int  i)

Checks to see if the NPC is important or not.

Definition at line 554 of file npc.c.

◆ npc_patchMission()

void npc_patchMission ( Mission misn)

Patches a new mission bar npc into the bar system.

Note
Do not reuse the pointer once it's fed.
Parameters
misnMission to patch in.

Definition at line 419 of file npc.c.

◆ npc_rm()

static int npc_rm ( NPC_t npc)
static

Removes an npc from the spaceport bar.

Definition at line 210 of file npc.c.

◆ npc_rm_event()

int npc_rm_event ( unsigned int  id,
unsigned int  evt 
)

removes an event NPC.

Definition at line 233 of file npc.c.

◆ npc_rm_mission()

int npc_rm_mission ( unsigned int  id,
unsigned int  mid 
)

removes a mission NPC.

Definition at line 255 of file npc.c.

◆ npc_rm_parentEvent()

int npc_rm_parentEvent ( unsigned int  id)

Removes all the npc belonging to an event.

Definition at line 277 of file npc.c.

◆ npc_rm_parentMission()

int npc_rm_parentMission ( unsigned int  mid)

Removes all the npc belonging to a mission.

Definition at line 301 of file npc.c.

◆ npc_sort()

void npc_sort ( void  )

Sorts the NPCs.

Definition at line 355 of file npc.c.

Variable Documentation

◆ npc_array

NPC_t* npc_array = NULL
static

Missions at the spaceport bar.

Definition at line 69 of file npc.c.

◆ npc_array_idgen

unsigned int npc_array_idgen = 0
static

ID generator.

Definition at line 68 of file npc.c.

◆ npc_missions

Mission* npc_missions = NULL
static

Definition at line 72 of file npc.c.