change shader properties to be vg_msg based
[carveJwlIkooP6JGAAIwe30JlM.git] / entity.c
index 21815f461973b2337c31da02df2622a7bc9dea42..ae506bd68fdc04fc39807abafc9cd1d5afaadb76 100644 (file)
--- a/entity.c
+++ b/entity.c
@@ -1,19 +1,21 @@
-#ifndef ENTITY_C
-#define ENTITY_C
-
 #include "world.h"
 #include "entity.h"
 #include "world_entity.h"
 
-#include "ent_skateshop.c"
-#include "ent_objective.c"
-#include "ent_challenge.c"
-#include "ent_relay.c"
-
-typedef void (*fn_entity_call_handler)( world_instance *, ent_call *);
+#include "ent_objective.h"
+#include "ent_skateshop.h"
+#include "ent_relay.h"
+#include "ent_challenge.h"
+#include "ent_route.h"
+#include "ent_miniworld.h"
+#include "ent_region.h"
+#include "ent_glider.h"
+#include "ent_npc.h"
 
-static void entity_call( world_instance *world, ent_call *call ){
-   u32 type = mdl_entity_id_type( call->id );
+void entity_call( world_instance *world, ent_call *call )
+{
+   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,
@@ -23,7 +25,12 @@ static void entity_call( world_instance *world, ent_call *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_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,
+      [k_ent_npc]       = ent_npc_call
    };
 
    if( type >= vg_list_size(table) ){
@@ -33,12 +40,32 @@ static 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; i<mdl_arrcount(arr); i++ ){
+      ent_marker *marker = mdl_arritm( arr, i );
+
+      if( !strcmp( mdl_pstr( mdl, marker->pstr_alias ), alias ) ){
+         return marker;
+      }
+   }
+
+   return NULL;
 }
 
-#endif /* ENTITY_C */