X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=entity.c;h=ffb5deed5d9c0c9e905e1c39335b80c8173e04fe;hb=5fa590f62aa7e62a8b6b07e10556c2ecc54cdca6;hp=261dbbcd2c1ba89c89b58d4ff45997eae0f2871a;hpb=5f6a4f9df6c8accc89f1920bfe9ace3cbac4c4b6;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/entity.c b/entity.c index 261dbbc..ffb5dee 100644 --- a/entity.c +++ b/entity.c @@ -10,12 +10,15 @@ #include "ent_miniworld.h" #include "ent_region.h" #include "ent_glider.h" +#include "ent_npc.h" +#include "world_water.h" -typedef void (*fn_entity_call_handler)( world_instance *, ent_call *); +#include void entity_call( world_instance *world, ent_call *call ) { - u32 type = mdl_entity_id_type( call->id ); + u32 type = mdl_entity_id_type( call->id ), + index = mdl_entity_id_id( call->id ); fn_entity_call_handler table[] = { [k_ent_volume] = ent_volume_call, @@ -29,7 +32,9 @@ void entity_call( world_instance *world, ent_call *call ) [k_ent_route] = ent_route_call, [k_ent_miniworld] = ent_miniworld_call, [k_ent_region] = ent_region_call, - [k_ent_glider] = ent_glider_call + [k_ent_glider] = ent_glider_call, + [k_ent_npc] = ent_npc_call, + [k_ent_water] = ent_water_call, }; if( type >= vg_list_size(table) ){ @@ -39,21 +44,30 @@ void entity_call( world_instance *world, ent_call *call ) fn_entity_call_handler fn = table[ type ]; - if( !fn ){ - vg_error( "call to entity type: %u is undefined\n", type ); + if( !fn ) + { + vg_error( "Entity type %u does not have a call handler, " + "but was called anyway\n", type ); return; } - fn( world, call ); + enum entity_call_result res = fn( world, call ); + + if( res == k_entity_call_result_unhandled ) + { + vg_warn( "Call to entity %u#%u was unhandled.\n", type, index ); + } } ent_marker *ent_find_marker( mdl_context *mdl, mdl_array_ptr *arr, const char *alias ) { - for( u32 i=0; ipstr_alias ), alias ) ){ + if( !strcmp( mdl_pstr( mdl, marker->pstr_alias ), alias ) ) + { return marker; } }