X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=entity.c;h=ce6d98eb76ecd959f572160c8f6c08f14b66d928;hb=refs%2Fheads%2Frigidbody;hp=1e85e565ecd89ce8ceafbe0316998e1c7b185e51;hpb=342fcbf6fda017bdd38d56ce0fa7c9e59e589f3b;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/entity.c b/entity.c index 1e85e56..ce6d98e 100644 --- a/entity.c +++ b/entity.c @@ -6,18 +6,48 @@ #include "world_entity.h" #include "ent_skateshop.c" +#include "ent_objective.c" +#include "ent_challenge.c" +#include "ent_relay.c" +#include "ent_route.c" +#include "ent_miniworld.c" +#include "ent_region.c" +#include "ent_traffic.c" +#include "ent_glider.c" -VG_STATIC void entity_call( world_instance *world, ent_call *call ) -{ +typedef void (*fn_entity_call_handler)( world_instance *, ent_call *); + +static void entity_call( world_instance *world, ent_call *call ){ u32 type = mdl_entity_id_type( call->id ); - if( type == k_ent_volume ){ - ent_volume_call( world, call ); - } else if( type == k_ent_audio ){ - ent_audio_call( world, call ); - } else if( type == k_ent_skateshop ){ - ent_skateshop_call( world, call ); + fn_entity_call_handler table[] = { + [k_ent_volume] = ent_volume_call, + [k_ent_audio] = ent_audio_call, + [k_ent_skateshop] = ent_skateshop_call, + [k_ent_objective] = ent_objective_call, + [k_ent_ccmd] = ent_ccmd_call, + [k_ent_gate] = ent_gate_call, + [k_ent_relay] = ent_relay_call, + [k_ent_challenge] = ent_challenge_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 + }; + + if( type >= vg_list_size(table) ){ + vg_error( "call to entity type: %u is out of range\n", type ); + return; + } + + fn_entity_call_handler fn = table[ type ]; + + if( !fn ){ + vg_error( "call to entity type: %u is undefined\n", type ); + return; } + + fn( world, call ); } #endif /* ENTITY_C */