Lines Matching refs:npc

75 static unsigned int npc_add( NPC_t *npc );
77 static int npc_rm( NPC_t *npc );
79 static void npc_free( NPC_t *npc );
85 static unsigned int npc_add( NPC_t *npc ) in npc_add() argument
91 npc_free( npc ); in npc_add()
103 *new_npc = *npc; in npc_add()
116 NPC_t npc; in npc_add_giver() local
119 npc.type = NPC_TYPE_GIVER; in npc_add_giver()
120 npc.name = strdup(misn->npc); in npc_add_giver()
121 npc.priority = misn->data->avail.priority; in npc_add_giver()
122 npc.portrait = gl_dupTexture(misn->portrait); in npc_add_giver()
123 npc.desc = strdup(misn->desc); in npc_add_giver()
124 npc.u.g = *misn; in npc_add_giver()
126 return npc_add( &npc ); in npc_add_giver()
136 NPC_t npc; in npc_add_mission() local
139 npc.type = NPC_TYPE_MISSION; in npc_add_mission()
140 npc.name = strdup( name ); in npc_add_mission()
141 npc.priority = priority; in npc_add_mission()
142 npc.portrait = gl_newImage( portrait, 0 ); in npc_add_mission()
143 npc.desc = strdup( desc ); in npc_add_mission()
144 npc.u.m.misn = misn; in npc_add_mission()
145 npc.u.m.func = strdup( func ); in npc_add_mission()
147 return npc_add( &npc ); in npc_add_mission()
157 NPC_t npc; in npc_add_event() local
160 npc.type = NPC_TYPE_EVENT; in npc_add_event()
161 npc.name = strdup( name ); in npc_add_event()
162 npc.priority = priority; in npc_add_event()
163 npc.portrait = gl_newImage( portrait, 0 ); in npc_add_event()
164 npc.desc = strdup( desc ); in npc_add_event()
165 npc.u.e.id = evt; in npc_add_event()
166 npc.u.e.func = strdup( func ); in npc_add_event()
168 return npc_add( &npc ); in npc_add_event()
175 static int npc_rm( NPC_t *npc ) in npc_rm() argument
177 npc_free(npc); in npc_rm()
179 array_erase( &npc_array, &npc[0], &npc[1] ); in npc_rm()
203 NPC_t *npc; in npc_rm_event() local
206 npc = npc_arrayGet( id ); in npc_rm_event()
207 if (npc == NULL) in npc_rm_event()
211 if (npc->type != NPC_TYPE_EVENT) in npc_rm_event()
215 if (npc->u.e.id != evt) in npc_rm_event()
219 return npc_rm( npc ); in npc_rm_event()
228 NPC_t *npc; in npc_rm_mission() local
231 npc = npc_arrayGet( id ); in npc_rm_mission()
232 if (npc == NULL) in npc_rm_mission()
236 if (npc->type != NPC_TYPE_MISSION) in npc_rm_mission()
240 if (misn->id != npc->u.m.misn->id) in npc_rm_mission()
244 return npc_rm( npc ); in npc_rm_mission()
254 NPC_t *npc; in npc_rm_parentEvent() local
261 npc = &npc_array[i]; in npc_rm_parentEvent()
262 if (npc->type != NPC_TYPE_EVENT) in npc_rm_parentEvent()
264 if (npc->u.e.id != id ) in npc_rm_parentEvent()
268 npc_rm( npc ); in npc_rm_parentEvent()
283 NPC_t *npc; in npc_rm_parentMission() local
290 npc = &npc_array[i]; in npc_rm_parentMission()
291 if (npc->type != NPC_TYPE_MISSION) in npc_rm_parentMission()
293 if (npc->u.m.misn->id != misn->id ) in npc_rm_parentMission()
297 npc_rm( npc ); in npc_rm_parentMission()
394 static void npc_free( NPC_t *npc ) in npc_free() argument
397 free(npc->name); in npc_free()
398 gl_freeTexture(npc->portrait); in npc_free()
399 free(npc->desc); in npc_free()
402 switch (npc->type) { in npc_free()
404 mission_cleanup(&npc->u.g); in npc_free()
408 free(npc->u.m.func); in npc_free()
412 free(npc->u.e.func); in npc_free()
554 static int npc_approach_giver( NPC_t *npc ) in npc_approach_giver() argument
570 misn = &npc->u.g; in npc_approach_giver()
575 npc_free( npc ); in npc_approach_giver()
576 array_erase( &npc_array, &npc[0], &npc[1] ); in npc_approach_giver()
593 NPC_t *npc; in npc_approach() local
600 npc = &npc_array[i]; in npc_approach()
603 switch (npc->type) { in npc_approach()
605 return npc_approach_giver( npc ); in npc_approach()
608 misn_runStart( npc->u.m.misn, npc->u.m.func ); in npc_approach()
609 lua_pushnumber( naevL, npc->id ); in npc_approach()
610 misn_runFunc( npc->u.m.misn, npc->u.m.func, 1 ); in npc_approach()
614 event_runStart( npc->u.e.id, npc->u.e.func ); in npc_approach()
615 lua_pushnumber( naevL, npc->id ); in npc_approach()
616 event_runFunc( npc->u.e.id, npc->u.e.func, 1 ); in npc_approach()