X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=ent_npc.c;h=7a4b484b534f22d389e3e3793cc15739a311109f;hb=HEAD;hp=d43122330120a34bbec263daed8f30d2f8ba1cf9;hpb=25c2e032930910c469e9f5278b8001b93f1a140a;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/ent_npc.c b/ent_npc.c index d431223..7a4b484 100644 --- a/ent_npc.c +++ b/ent_npc.c @@ -70,7 +70,7 @@ static struct npc *npc_resolve( u32 id ) else return NULL; } -static void npc_slowmo_call( ent_npc *npc, ent_call *call ) +static entity_call_result npc_slowmo_call( ent_npc *npc, ent_call *call ) { if( call->function == 0 ) { @@ -96,22 +96,26 @@ static void npc_slowmo_call( ent_npc *npc, ent_call *call ) if( gui_new_helper( input_button_list[k_srbind_replay_resume], &text )) vg_strcat( &text, "Resume" ); } + return k_entity_call_result_OK; } else if( call->function == -1 ) { world_entity_clear_focus(); gui_helper_clear(); + return k_entity_call_result_OK; } + else + return k_entity_call_result_unhandled; } -void ent_npc_call( world_instance *world, ent_call *call ) +entity_call_result ent_npc_call( world_instance *world, ent_call *call ) { u32 index = mdl_entity_id_id( call->id ); ent_npc *npc = mdl_arritm( &world->ent_npc, index ); if( npc->id == 2 ) { - npc_slowmo_call( npc, call ); + return npc_slowmo_call( npc, call ); } else if( npc->id == 3 ) { @@ -122,12 +126,16 @@ void ent_npc_call( world_instance *world, ent_call *call ) vg_str text; if( gui_new_helper( input_button_list[k_srbind_maccept], &text )) vg_strcat( &text, "Preview course" ); + return k_entity_call_result_OK; } else if( call->function == -1 ) { world_entity_clear_focus(); gui_helper_clear(); + return k_entity_call_result_OK; } + else + return k_entity_call_result_unhandled; } else if( npc->id == 4 ) { @@ -137,11 +145,15 @@ void ent_npc_call( world_instance *world, ent_call *call ) vg_str text; if( gui_new_helper( input_button_list[k_srbind_camera], &text )) vg_strcat( &text, "First/Thirdperson" ); + return k_entity_call_result_OK; } else if( call->function == -1 ) { gui_helper_clear(); + return k_entity_call_result_OK; } + else + return k_entity_call_result_unhandled; } else { @@ -152,25 +164,25 @@ void ent_npc_call( world_instance *world, ent_call *call ) vg_str text; if( gui_new_helper( input_button_list[k_srbind_maccept], &text )) vg_strcat( &text, "Talk to ???" ); + return k_entity_call_result_OK; } else if( call->function == -1 ) { world_entity_clear_focus(); gui_helper_clear(); + return k_entity_call_result_OK; } else - { - vg_print_backtrace(); - vg_error( "Unhandled function id: %i\n", call->function ); - } + return k_entity_call_result_unhandled; } } -void ent_npc_preupdate( ent_npc *ent, int active ) +void ent_npc_preupdate( ent_focus_context *ctx ) { - world_instance *world = world_current_instance(); + world_instance *world = ctx->world; + ent_npc *ent = mdl_arritm( &world->ent_npc, ctx->index ); - if( !active ) + if( !ctx->active ) { if( button_down(k_srbind_maccept) ) {