achievements and stuff
[carveJwlIkooP6JGAAIwe30JlM.git] / world.h
diff --git a/world.h b/world.h
index bf81595c296de4c02ac6c967f6b56c49ebd42b3e..7f8432ab08d9f0630777be8aa1e33db78cac529f 100644 (file)
--- a/world.h
+++ b/world.h
@@ -58,6 +58,17 @@ static struct gworld
    spawns[32];
    u32 spawn_count;
 
+   struct achievement_zone
+   {
+      m4x3f transform, inv_transform;
+      char name[32];
+      int triggered;
+   }
+   * achievement_zones;
+
+   u32 achievement_zones_count,
+       achievement_zones_cap;
+
    struct subworld_routes
    {
       struct route_node
@@ -288,6 +299,7 @@ static void world_free( void *_ )
 {
    mesh_free( &world.cars );
    mesh_free( &world.skydome );
+   vg_free( world.achievement_zones );
 }
 
 static void world_update( v3f pos )
@@ -331,6 +343,30 @@ static void world_update( v3f pos )
          }
       }
    }
+
+   for( int i=0; i<world.achievement_zones_count; i++ )
+   {
+      struct achievement_zone *zone = &world.achievement_zones[i];
+
+      if( zone->triggered )
+         continue;
+
+      v3f local;
+      m4x3_mulv( zone->inv_transform, pos, local );
+      
+      if( (fabsf(local[0]) <= 1.0f) &&
+          (fabsf(local[1]) <= 1.0f) &&
+          (fabsf(local[2]) <= 1.0f) )
+      {
+         zone->triggered = 1;
+         steam_set_achievement( zone->name );
+         steam_store_achievements();
+      }
+
+      vg_line_boxf_transformed( zone->transform, (boxf){{-1.0f,-1.0f,-1.0f},
+                                                        { 1.0f, 1.0f, 1.0f}}, 
+                                                        0xff00ff00 );
+   }
    
    sfd_update( &world.sfd.tester );
 }