stuff
authorhgn <hgodden00@gmail.com>
Fri, 30 Sep 2022 00:31:35 +0000 (01:31 +0100)
committerhgn <hgodden00@gmail.com>
Fri, 30 Sep 2022 00:31:35 +0000 (01:31 +0100)
43 files changed:
audio.h
blender_export.py
highscores.h
main.c
model.h
models_src/mp_dev.mdl
network.h
player.h
sound_src/garden_generic.ogg [new file with mode: 0644]
sound_src/jump0.ogg [new file with mode: 0644]
sound_src/jump1.ogg [new file with mode: 0644]
sound_src/jump2.ogg [new file with mode: 0644]
sound_src/jump3.ogg [new file with mode: 0644]
sound_src/mis2.ogg [new file with mode: 0644]
sound_src/misc0.ogg [new file with mode: 0644]
sound_src/misc1.ogg [new file with mode: 0644]
sound_src/misc3.ogg [new file with mode: 0644]
sound_src/misc5.ogg [new file with mode: 0644]
sound_src/misc6.ogg [new file with mode: 0644]
sound_src/misk4.ogg [new file with mode: 0644]
sound_src/step_bush0.ogg [new file with mode: 0644]
sound_src/step_bush1.ogg [new file with mode: 0644]
sound_src/step_bush2.ogg [new file with mode: 0644]
sound_src/step_bush3.ogg [new file with mode: 0644]
sound_src/step_bush4.ogg [new file with mode: 0644]
sound_src/step_bush5.ogg [new file with mode: 0644]
sound_src/step_concrete0.ogg [new file with mode: 0644]
sound_src/step_concrete1.ogg [new file with mode: 0644]
sound_src/step_concrete2.ogg [new file with mode: 0644]
sound_src/step_concrete3.ogg [new file with mode: 0644]
sound_src/step_gravel0.ogg [new file with mode: 0644]
sound_src/step_gravel1.ogg [new file with mode: 0644]
sound_src/step_gravel2.ogg [new file with mode: 0644]
sound_src/step_gravel3.ogg [new file with mode: 0644]
sound_src/step_wood0.ogg [new file with mode: 0644]
sound_src/step_wood1.ogg [new file with mode: 0644]
sound_src/step_wood2.ogg [new file with mode: 0644]
sound_src/step_wood3.ogg [new file with mode: 0644]
sound_src/step_wood4.ogg [new file with mode: 0644]
sound_src/step_wood5.ogg [new file with mode: 0644]
world.h
world_info.h
world_routes.h

diff --git a/audio.h b/audio.h
index a9815861680d4c247b83f8dd8d23a7c4908855fb..3eeace9575098e51d1dbbdf4d5b5e29dde965710 100644 (file)
--- a/audio.h
+++ b/audio.h
@@ -22,10 +22,17 @@ audio_clip audio_ding =
 { .path = "sound/ding.ogg", .source_mode=k_audio_source_compressed };
 
 audio_clip audio_jumps[] = {
-   { .path = "sound/snap0.ogg", .source_mode=k_audio_source_compressed, },
-   { .path = "sound/snap1.ogg", .source_mode=k_audio_source_compressed, },
-   { .path = "sound/snap2.ogg", .source_mode=k_audio_source_compressed, },
-   { .path = "sound/snap3.ogg", .source_mode=k_audio_source_compressed, }
+   { .path = "sound/jump0.ogg", .source_mode=k_audio_source_compressed, },
+   { .path = "sound/jump1.ogg", .source_mode=k_audio_source_compressed, },
+   { .path = "sound/jump2.ogg", .source_mode=k_audio_source_compressed, },
+   { .path = "sound/jump3.ogg", .source_mode=k_audio_source_compressed, }
+};
+
+audio_clip audio_footsteps[] = {
+ {.path = "sound/step_concrete0.ogg", .source_mode=k_audio_source_compressed,},
+ {.path = "sound/step_concrete1.ogg", .source_mode=k_audio_source_compressed,},
+ {.path = "sound/step_concrete2.ogg", .source_mode=k_audio_source_compressed,},
+ {.path = "sound/step_concrete3.ogg", .source_mode=k_audio_source_compressed,}
 };
 
 audio_clip audio_lands[] = {
@@ -107,6 +114,7 @@ static void audio_init(void)
    audio_clip_loadn( &audio_gate_ambient, 1 );
    audio_clip_loadn( audio_jumps, vg_list_size(audio_jumps) );
    audio_clip_loadn( audio_lands, vg_list_size(audio_lands) );
+   audio_clip_loadn( audio_footsteps, vg_list_size(audio_footsteps) );
 
    audio_lock();
    u32 flags = AUDIO_FLAG_LOOP|AUDIO_FLAG_SPACIAL_3D;
index a8061e4ed9241baa12cd77c379284a94fcb9339e..c44694abc0ea5b6e41e36fec86cdfaa1ff5ce181 100644 (file)
@@ -132,8 +132,7 @@ class classtype_route_node(Structure):
 
 class classtype_route(Structure):
    _pack_ = 1
-   _fields_ = [("pstr_name",c_uint32),
-               ("id_start",c_uint32),
+   _fields_ = [("id_start",c_uint32),
                ("colour",c_float*3)]
 
 class classtype_skin(Structure):
@@ -158,21 +157,6 @@ class classtype_bone(Structure):
                ("angle_limits",(c_float*3)*2),
                ("hitbox",(c_float*3)*2)]
 
-class subclass_audio_channel(Structure):
-   _pack_ = 1
-   _fields_ = [("sound",c_uint32),
-               ("target",c_uint32),
-               ("")]
-
-class classtype_audio_system(Structure):
-   _pack_ = 1
-   _fields_ = [("sounds", subclass_audio_channel * 4),
-               ("len", c_uint32)]
-
-class classtype_audio_zone(Structure):
-   _pack_ = 1
-   _fields_ = [("system",c_uint32)]
-
 # Exporter
 # ==============================================================================
 
@@ -870,7 +854,6 @@ def write_model(collection_name):
          node.classtype = 9
          entdata_length += sizeof( classtype_route )
          r = classtype_route()
-         r.pstr_name = emplace_string("not-implemented")
          r.colour[0] = obj.cv_data.colour[0]
          r.colour[1] = obj.cv_data.colour[1]
          r.colour[2] = obj.cv_data.colour[2]
index b1c9cc0a5d591794388213552ab1938a75003a0b..2c077b1038a9d9f5fdf90fe8ba855a005d3243ff 100644 (file)
@@ -293,6 +293,23 @@ static int highscores_serialize_all(void)
    return 1;
 }
 
+static highscore_record *highscore_find_user_record( u64 playerid, u32 trackid )
+{
+   struct highscore_system *sys = &highscore_system;
+
+   highscore_track_table *table = &sys->dbheader.tracks[trackid];
+   highscore_record temp;
+   temp.playerid = playerid;
+
+   aatree_ptr find = 
+      aatree_find( &sys->aainfo_playerid, table->root_playerid, &temp );
+
+   if( find == AATREE_PTR_NIL )
+      return NULL;
+
+   return aatree_get_data( &sys->aainfo_playerid, find );
+}
+
 static aatree_ptr highscores_push_record( highscore_record *record )
 {
    struct highscore_system *sys = &highscore_system;
@@ -578,11 +595,11 @@ static void highscores_board_generate( char *buf, u32 id, u32 count )
          highscore_strl( line+3, inf->nickname, 10 );
       }
 
-      u16 miliseconds = record->time,
-          seconds     = miliseconds / 100,
-          minutes     = seconds / 60;
+      u16 centiseconds = record->time,
+          seconds      = centiseconds / 100,
+          minutes      = seconds / 60;
 
-      miliseconds %= 100;
+      centiseconds %= 100;
       seconds     %= 60;
       minutes     %= 60;
 
@@ -593,10 +610,10 @@ static void highscores_board_generate( char *buf, u32 id, u32 count )
       line[15] = ':';
       highscore_intr( line+16, seconds, 2, '0' );
       line[18] = '.';
-      highscore_intr( line+19, miliseconds, 2, '0' );
+      highscore_intr( line+19, centiseconds, 2, '0' );
 
       /* Score */
-      highscore_intl( line+22, record->time, 5 );
+      highscore_intl( line+22, record->points, 5 );
       it = aatree_next( &sys->aainfo_time, it );
    }
 }
diff --git a/main.c b/main.c
index c306aa50f1292a0701fae233776fe14b7a4a67ee..7495ff34d9b5368422934a50063a89a64c2d8cdc 100644 (file)
--- a/main.c
+++ b/main.c
@@ -21,7 +21,7 @@ static int sv_scene = 0;
 static int cl_ui = 1;
 
 /* Components */
-//#define SR_NETWORKED
+#define SR_NETWORKED
 
 /* uncomment this to run the game without any graphics being drawn */
 //#define SR_NETWORK_TEST
@@ -88,6 +88,7 @@ vg_tex2d *texture_list[] =
 
 int main( int argc, char *argv[] )
 { 
+   highscores_init( 2000, 50 );
    vg_init( argc, argv, "Voyager Game Engine" ); 
 }
 
@@ -254,6 +255,9 @@ void vg_free(void)
    vg_tex2d_free( texture_list, vg_list_size(texture_list) );
    /* TODO: THE REST OF THE GOD DAMN FREEING STUFF */
    steam_end();
+
+   highscores_serialize_all();
+   highscores_free();
 }
 
 void vg_update(void)
diff --git a/model.h b/model.h
index 78e67c0367ba9dcbc0a855afa688ee95a8a255a8..24dacb875434d57f2328f0034edb24c7ce10ca6e 100644 (file)
--- a/model.h
+++ b/model.h
@@ -142,7 +142,6 @@ struct classtype_route_node
 
 struct classtype_route
 {
-   u32 pstr_name;
    u32 id_start;
    v3f colour;
 };
index 6364062545b4cb7fdebd0de229cf823d7b4c0924..d33e7b18ef6eb6ba56ea999e626e2fa0731ad8d2 100644 (file)
Binary files a/models_src/mp_dev.mdl and b/models_src/mp_dev.mdl differ
index 998a367a44b9eb04270288006d2475cb9c6a536f..1ffb06b8bb496d5996016adc27ff231d66e96c42 100644 (file)
--- a/network.h
+++ b/network.h
@@ -9,7 +9,7 @@
 /* 
  * Interface
  */
-#define SR_USE_LOCALHOST
+//#define SR_USE_LOCALHOST
 
 /* Call it at start; Connects us to the gameserver */
 static void network_init(void);
@@ -122,18 +122,42 @@ static void send_score_update(void)
 {
    vg_info( "Sending scores\n" );
    u32 size = sizeof(netmsg_set_score) + 
-                  1 * sizeof(struct netmsg_score_record);
-
+                  vg_list_size(track_infos)*sizeof(struct netmsg_score_record);
    netmsg_set_score *setscore = alloca( size );
    setscore->inetmsg_id = k_inetmsg_set_score;
-   setscore->record_count = 1;
-   setscore->records[0].trackid = 0;
-   setscore->records[0].playerid = 0;
-   setscore->records[0].points = 1386;
-   setscore->records[0].time = 19432;
+
+   int count = 0;
+   for( u32 i=0; i<vg_list_size(track_infos); i++ )
+   {
+      if( track_infos[i].push )
+      {
+         track_infos[i].push = 0;
+         highscore_record *user_record = highscore_find_user_record( 0, i );
+
+         if( !user_record )
+         {
+            vg_error( "No score set but tried to upload for track %u\n", i );
+            continue;
+         }
+
+         setscore->records[count].trackid = i;
+         setscore->records[count].playerid = 0;
+         setscore->records[count].points = user_record->points;
+         setscore->records[count].time = user_record->time;
+
+         count ++;
+      }
+   }
+
+   if( count == 0 )
+      return;
+
+   u32 send_size = sizeof(netmsg_set_score) +
+                  count*sizeof(struct netmsg_score_record);
+   setscore->record_count = count;
 
    SteamAPI_ISteamNetworkingSockets_SendMessageToConnection(
-         hSteamNetworkingSockets, cremote, setscore, size,
+         hSteamNetworkingSockets, cremote, setscore, send_size,
          k_nSteamNetworkingSend_Reliable, NULL );
 }
 
@@ -143,7 +167,7 @@ static void send_nickname(void)
    nick.inetmsg_id = k_inetmsg_set_nickname;
 
    memset( nick.nickname, 0, 10 );
-   strcpy( nick.nickname, "real H" );
+   strcpy( nick.nickname, "Harry" );
    
    SteamAPI_ISteamNetworkingSockets_SendMessageToConnection(
          hSteamNetworkingSockets, cremote, &nick, sizeof(netmsg_set_nickname),
index 7f02ec0eee4e0f09e5b18bded7da3938bd266b61..97c799ee61ca7d151999b14ca0aa5a9c38b4621d 100644 (file)
--- a/player.h
+++ b/player.h
@@ -92,6 +92,9 @@ static struct gplayer
          fsetup,
          walk_timer,
          fonboard;
+
+   v3f last_step_pos;
+   int step_phase;
 }
 player = 
 {
@@ -519,6 +522,8 @@ static void player_walk_physics(void)
          }
       }
    }
+
+   player.in_air = len==0?1:0;
    
    v3_zero( player.rb.w );
    q_axis_angle( player.rb.q, (v3f){0.0f,1.0f,0.0f}, -player.angles[0] );
@@ -544,8 +549,8 @@ static void player_walk_physics(void)
       v3_muladds( player.rb.v, forward_dir, diff, player.rb.v );
 
       /* TODO move */
-      float walk_norm = (float)player.mdl.anim_walk->length / 30.0f,
-            run_norm  = (float)player.mdl.anim_run->length  / 30.0f;
+      float walk_norm = 30.0f/(float)player.mdl.anim_walk->length,
+            run_norm  = 30.0f/(float)player.mdl.anim_run->length ;
 
       player.walk_timer += ktimestep * vg_lerpf( walk_norm,run_norm,move_norm );
    }
@@ -723,7 +728,7 @@ static void player_physics(void)
          audio_lock();
          audio_player_set_flags( &audio_player_extra, AUDIO_FLAG_SPACIAL_3D );
          audio_player_set_position( &audio_player_extra, player.rb.co );
-         audio_player_set_vol( &audio_player_extra, 3.0f );
+         audio_player_set_vol( &audio_player_extra, 20.0f );
          audio_player_playclip( &audio_player_extra, &audio_jumps[rand()%4] );
          audio_unlock();
       }
@@ -829,13 +834,13 @@ static void player_animate_offboard(void)
    mdl_keyframe apose[32], bpose[32];
    struct skeleton *sk = &player.mdl.sk;
 
-   float walk_norm = 30.0f/(float)player.mdl.anim_walk->length,
-         run_norm  = 30.0f/(float)player.mdl.anim_run->length,
+   float walk_norm = (float)player.mdl.anim_walk->length/30.0f,
+         run_norm  = (float)player.mdl.anim_run->length/30.0f,
          t = player.walk_timer,
          l = vg_get_axis("grabr") * 0.5f + 0.5f;
 
    skeleton_sample_anim( sk, player.mdl.anim_walk, t*walk_norm, apose );
-   skeleton_sample_anim( sk, player.mdl.anim_run,  t*run_norm,  bpose );
+   skeleton_sample_anim( sk, player.mdl.anim_run,  t*run_norm, bpose );
 
    skeleton_lerp_pose( sk, apose, bpose, l, apose );
 
@@ -1170,7 +1175,8 @@ static void player_audio(void)
    audio_lock();
    
    double revert_delta = vg_time - last_revert;
-   if( (!_air && l2) && (fabsf(player.slip) > 0.5f) && (revert_delta > 0.7) )
+   if( player.on_board && (!_air && l2) && (fabsf(player.slip) > 0.5f) && 
+         (revert_delta > 0.7) )
    {
       audio_player_set_position( &audio_player_extra, player.rb.co );
       audio_player_set_flags( &audio_player_extra, AUDIO_FLAG_SPACIAL_3D );
@@ -1214,6 +1220,25 @@ static void player_audio(void)
       audio_player_set_vol( &audio_player0, 0.0f );
       audio_player_set_vol( &audio_player1, 0.0f );
       audio_player_set_vol( &audio_player2, 0.0f );
+
+      int walk_phase = 0;
+      if( vg_fractf(player.walk_timer) > 0.5f )
+         walk_phase = 1;
+      else
+         walk_phase = 0;
+
+      if( (player.step_phase != walk_phase) && !player.in_air )
+      {
+         v3_copy( player.rb.co, player.last_step_pos );
+
+         audio_player_set_flags( &audio_player_extra, AUDIO_FLAG_SPACIAL_3D );
+         audio_player_set_position( &audio_player_extra, player.rb.co );
+         audio_player_set_vol( &audio_player_extra, 6.0f );
+         audio_player_playclip( &audio_player_extra, 
+                                          &audio_footsteps[rand()%4] );
+      }
+
+      player.step_phase = walk_phase;
    }
    else
    {
diff --git a/sound_src/garden_generic.ogg b/sound_src/garden_generic.ogg
new file mode 100644 (file)
index 0000000..efe5871
Binary files /dev/null and b/sound_src/garden_generic.ogg differ
diff --git a/sound_src/jump0.ogg b/sound_src/jump0.ogg
new file mode 100644 (file)
index 0000000..c1fce98
Binary files /dev/null and b/sound_src/jump0.ogg differ
diff --git a/sound_src/jump1.ogg b/sound_src/jump1.ogg
new file mode 100644 (file)
index 0000000..c4d3a6c
Binary files /dev/null and b/sound_src/jump1.ogg differ
diff --git a/sound_src/jump2.ogg b/sound_src/jump2.ogg
new file mode 100644 (file)
index 0000000..cb9f59f
Binary files /dev/null and b/sound_src/jump2.ogg differ
diff --git a/sound_src/jump3.ogg b/sound_src/jump3.ogg
new file mode 100644 (file)
index 0000000..0380bf5
Binary files /dev/null and b/sound_src/jump3.ogg differ
diff --git a/sound_src/mis2.ogg b/sound_src/mis2.ogg
new file mode 100644 (file)
index 0000000..e8df3bd
Binary files /dev/null and b/sound_src/mis2.ogg differ
diff --git a/sound_src/misc0.ogg b/sound_src/misc0.ogg
new file mode 100644 (file)
index 0000000..e1b6635
Binary files /dev/null and b/sound_src/misc0.ogg differ
diff --git a/sound_src/misc1.ogg b/sound_src/misc1.ogg
new file mode 100644 (file)
index 0000000..6dc526f
Binary files /dev/null and b/sound_src/misc1.ogg differ
diff --git a/sound_src/misc3.ogg b/sound_src/misc3.ogg
new file mode 100644 (file)
index 0000000..9feb230
Binary files /dev/null and b/sound_src/misc3.ogg differ
diff --git a/sound_src/misc5.ogg b/sound_src/misc5.ogg
new file mode 100644 (file)
index 0000000..301704d
Binary files /dev/null and b/sound_src/misc5.ogg differ
diff --git a/sound_src/misc6.ogg b/sound_src/misc6.ogg
new file mode 100644 (file)
index 0000000..5c740fb
Binary files /dev/null and b/sound_src/misc6.ogg differ
diff --git a/sound_src/misk4.ogg b/sound_src/misk4.ogg
new file mode 100644 (file)
index 0000000..29e1c1c
Binary files /dev/null and b/sound_src/misk4.ogg differ
diff --git a/sound_src/step_bush0.ogg b/sound_src/step_bush0.ogg
new file mode 100644 (file)
index 0000000..9915390
Binary files /dev/null and b/sound_src/step_bush0.ogg differ
diff --git a/sound_src/step_bush1.ogg b/sound_src/step_bush1.ogg
new file mode 100644 (file)
index 0000000..ed3f61b
Binary files /dev/null and b/sound_src/step_bush1.ogg differ
diff --git a/sound_src/step_bush2.ogg b/sound_src/step_bush2.ogg
new file mode 100644 (file)
index 0000000..6a1e497
Binary files /dev/null and b/sound_src/step_bush2.ogg differ
diff --git a/sound_src/step_bush3.ogg b/sound_src/step_bush3.ogg
new file mode 100644 (file)
index 0000000..690ddb4
Binary files /dev/null and b/sound_src/step_bush3.ogg differ
diff --git a/sound_src/step_bush4.ogg b/sound_src/step_bush4.ogg
new file mode 100644 (file)
index 0000000..b15a526
Binary files /dev/null and b/sound_src/step_bush4.ogg differ
diff --git a/sound_src/step_bush5.ogg b/sound_src/step_bush5.ogg
new file mode 100644 (file)
index 0000000..bab49f0
Binary files /dev/null and b/sound_src/step_bush5.ogg differ
diff --git a/sound_src/step_concrete0.ogg b/sound_src/step_concrete0.ogg
new file mode 100644 (file)
index 0000000..5fad2a8
Binary files /dev/null and b/sound_src/step_concrete0.ogg differ
diff --git a/sound_src/step_concrete1.ogg b/sound_src/step_concrete1.ogg
new file mode 100644 (file)
index 0000000..a65d1d3
Binary files /dev/null and b/sound_src/step_concrete1.ogg differ
diff --git a/sound_src/step_concrete2.ogg b/sound_src/step_concrete2.ogg
new file mode 100644 (file)
index 0000000..1920a9d
Binary files /dev/null and b/sound_src/step_concrete2.ogg differ
diff --git a/sound_src/step_concrete3.ogg b/sound_src/step_concrete3.ogg
new file mode 100644 (file)
index 0000000..45ce8be
Binary files /dev/null and b/sound_src/step_concrete3.ogg differ
diff --git a/sound_src/step_gravel0.ogg b/sound_src/step_gravel0.ogg
new file mode 100644 (file)
index 0000000..a3f8e81
Binary files /dev/null and b/sound_src/step_gravel0.ogg differ
diff --git a/sound_src/step_gravel1.ogg b/sound_src/step_gravel1.ogg
new file mode 100644 (file)
index 0000000..53c87f1
Binary files /dev/null and b/sound_src/step_gravel1.ogg differ
diff --git a/sound_src/step_gravel2.ogg b/sound_src/step_gravel2.ogg
new file mode 100644 (file)
index 0000000..e72e000
Binary files /dev/null and b/sound_src/step_gravel2.ogg differ
diff --git a/sound_src/step_gravel3.ogg b/sound_src/step_gravel3.ogg
new file mode 100644 (file)
index 0000000..cc67c14
Binary files /dev/null and b/sound_src/step_gravel3.ogg differ
diff --git a/sound_src/step_wood0.ogg b/sound_src/step_wood0.ogg
new file mode 100644 (file)
index 0000000..10d94ba
Binary files /dev/null and b/sound_src/step_wood0.ogg differ
diff --git a/sound_src/step_wood1.ogg b/sound_src/step_wood1.ogg
new file mode 100644 (file)
index 0000000..33c9621
Binary files /dev/null and b/sound_src/step_wood1.ogg differ
diff --git a/sound_src/step_wood2.ogg b/sound_src/step_wood2.ogg
new file mode 100644 (file)
index 0000000..adf21c5
Binary files /dev/null and b/sound_src/step_wood2.ogg differ
diff --git a/sound_src/step_wood3.ogg b/sound_src/step_wood3.ogg
new file mode 100644 (file)
index 0000000..ee3e76e
Binary files /dev/null and b/sound_src/step_wood3.ogg differ
diff --git a/sound_src/step_wood4.ogg b/sound_src/step_wood4.ogg
new file mode 100644 (file)
index 0000000..2485d2c
Binary files /dev/null and b/sound_src/step_wood4.ogg differ
diff --git a/sound_src/step_wood5.ogg b/sound_src/step_wood5.ogg
new file mode 100644 (file)
index 0000000..3af0687
Binary files /dev/null and b/sound_src/step_wood5.ogg differ
diff --git a/world.h b/world.h
index 2fa7ce4f5ada984e5e4059d477e3e9eeb0823be7..9d35d304be7e8c6682f73e5cdae665857cd43749 100644 (file)
--- a/world.h
+++ b/world.h
@@ -88,6 +88,7 @@ static struct gworld
        instance_cache_cap;
 
    v3f render_gate_pos;
+   int active_route_board;
 }
 world;
 
@@ -550,6 +551,8 @@ static void world_update(void)
 {
    world_routes_update();
    world_routes_debug();
+   
+   
    sfd_update( &world.sfd.tester );
 
 #if 0
@@ -752,15 +755,23 @@ static void render_world( m4x4f projection, m4x3f camera )
    render_world_alphatest( projection, camera[3] );
    render_terrain( projection, camera[3] );
 
-   m4x3f identity_matrix;
-   m4x3_identity( identity_matrix );
-   identity_matrix[3][1] = 125.0f;
+   int closest = 0;
+   float min_dist = INFINITY;
 
-   v4f t;
-   q_axis_angle( t, (v3f){0.0f,1.0f,0.0f}, 2.3f );
-   q_m3x3( t, identity_matrix );
+   for( int i=0; i<world.routes.route_count; i++ )
+   {
+      float dist = v3_dist2( world.routes.routes[i].scoreboard_transform[3],
+                              camera[3] );
+
+      if( dist < min_dist )
+      {
+         min_dist = dist;
+         closest = i;
+      }
+   }
 
-   //sfd_render( &world.sfd.tester, projection, camera[3], identity_matrix );
+   sfd_render( &world.sfd.tester, projection, camera[3], 
+         world.routes.routes[closest].scoreboard_transform );
 }
 
 static void render_world_depth( m4x4f projection, m4x3f camera )
index a8d42d8b56e378331ecb6b3a7743a098419ead80..215d05504bd4d49b61e1c5885ddaa472acaa4ba8 100644 (file)
@@ -15,20 +15,33 @@ world_info;
 static struct track_info
 {
    const char *name;
+   int push;
 }
 track_infos[] = 
 {
    {
-      .name = "Megapark Green"
+      .name = "Megapark Green",
+      .push = 1
    },
    {
-      .name = "Megapark Blue"
+      .name = "Megapark Blue",
+      .push = 1
    },
    {
-      .name = "Megapark Yellow"
+      .name = "Megapark Yellow",
+      .push = 1
    },
    {
-      .name = "Megapark Red"
+      .name = "Megapark Red",
+      .push = 1
+   },
+   {
+      .name = "Town Coast (Blue)",
+      .push = 1
+   },
+   {
+      .name = "Town Downhill (Orange)",
+      .push = 1
    }
 };
 
index f899694a574668e08d4a19454f1bf3bc7764b33b..9cee0df0d19b38dbd41b5c84042cc9cdaded5b83 100644 (file)
@@ -4,6 +4,8 @@
 #include "common.h"
 #include "model.h"
 #include "gate.h"
+#include "world_info.h"
+#include "highscores.h"
 
 #include "shaders/vblend.h"
 #include "shaders/route.h"
@@ -36,7 +38,7 @@ struct subworld_routes
 
    struct route
    {
-      const char *name;
+      u32 track_id;
       v4f colour;
 
       u32 start;
@@ -69,6 +71,8 @@ struct subworld_routes
          float xpos;
       }
       ui;
+
+      m4x3f scoreboard_transform;
    }
    *routes;
 
@@ -550,6 +554,35 @@ static void world_routes_ui_draw( u32 route, v4f colour, float offset )
    pr->ui.xpos = vg_lerpf( pr->ui.xpos, -main_block_size * 0.5f, 0.03f );
 }
 
+static void world_routes_local_set_record( u32 route, double lap_time )
+{
+   vg_success( "  NEW LAP TIME: %f\n", lap_time );
+
+   struct subworld_routes *r = subworld_routes();
+   struct route *pr = &r->routes[route];
+
+   if( pr->track_id != 0xffffffff )
+   {
+      double time_centiseconds = lap_time * 100.0;
+      if( time_centiseconds > (float)0xfffe )
+         return;
+
+      highscore_record temp;
+      temp.trackid  = pr->track_id;
+      temp.datetime = time(NULL);
+      temp.playerid = 0;
+      temp.points   = 0;
+      temp.time     = time_centiseconds;
+
+      highscores_push_record( &temp );
+      track_infos[ pr->track_id ].push = 1;
+   }
+   else
+   {
+      vg_warn( "There is no associated track for this record...\n" );
+   }
+}
+
 /* 
  * Will scan the whole run for two things;
  *   1: we set a new record for the total, complete loop around the course
@@ -635,7 +668,7 @@ static void world_routes_verify_run( u32 route )
 
    if( verified )
    {
-      vg_success( "  NEW LAP TIME: %f\n", lap_time );
+      world_routes_local_set_record( route, lap_time );
       world_routes_ui_popfirst(route);
       pr->ui.fade_count ++;
    }
@@ -1106,10 +1139,21 @@ static void world_routes_loadfrom( mdl_header *mdl )
          v3_copy( inf->colour, route->colour );
          route->colour[3] = 1.0f;
 
-         route->name = NULL;
+
+         route->track_id = 0xffffffff;
+         for( u32 j=0; j<vg_list_size(track_infos); j++ )
+         {
+            if( !strcmp( mdl_pstr(mdl,pnode->pstr_name), track_infos[j].name ))
+            {
+               route->track_id = j;
+               break;
+            }
+         }
+
          route->start = inf->id_start;
          route->active = 0;
          route->factive = 0.0f;
+         mdl_node_transform( pnode, route->scoreboard_transform );
 
          /* OpenGL strips */
          glGenVertexArrays( 1, &route->ui.vao );