From: hgn Date: Fri, 30 Sep 2022 00:31:35 +0000 (+0100) Subject: stuff X-Git-Url: https://harrygodden.com/git/?a=commitdiff_plain;ds=sidebyside;h=ba5f879f85b9cab1e2b37241399d79709fe4f584;hp=a9f402f2e336dadff2207dacf69416a66f50c8f8;p=carveJwlIkooP6JGAAIwe30JlM.git stuff --- diff --git a/audio.h b/audio.h index a981586..3eeace9 100644 --- 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; diff --git a/blender_export.py b/blender_export.py index a8061e4..c44694a 100644 --- a/blender_export.py +++ b/blender_export.py @@ -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] diff --git a/highscores.h b/highscores.h index b1c9cc0..2c077b1 100644 --- a/highscores.h +++ b/highscores.h @@ -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 c306aa5..7495ff3 100644 --- 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 78e67c0..24dacb8 100644 --- 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; }; diff --git a/models_src/mp_dev.mdl b/models_src/mp_dev.mdl index 6364062..d33e7b1 100644 Binary files a/models_src/mp_dev.mdl and b/models_src/mp_dev.mdl differ diff --git a/network.h b/network.h index 998a367..1ffb06b 100644 --- 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; irecords[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), diff --git a/player.h b/player.h index 7f02ec0..97c799e 100644 --- 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 index 0000000..3af0687 Binary files /dev/null and b/sound_src/step_wood5.ogg differ diff --git a/world.h b/world.h index 2fa7ce4..9d35d30 100644 --- 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; iui.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; jpstr_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 );