X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=world_sfd.c;h=b40d57a5896cf8ffad66360d4af238fc993b42da;hb=a7d144c7905105909cc4434e0ab43008bbb8f89f;hp=9fe2d68e76743060909b200e8ef97fc54152c0c3;hpb=342fcbf6fda017bdd38d56ce0fa7c9e59e589f3b;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/world_sfd.c b/world_sfd.c index 9fe2d68..b40d57a 100644 --- a/world_sfd.c +++ b/world_sfd.c @@ -4,9 +4,10 @@ #include "world_sfd.h" #include "shaders/scene_scoretext.h" #include "shaders/scene_vertex_blend.h" +#include "network.h" +#include "entity.h" -static f32 sfd_encode_glyph( char c ) -{ +static f32 sfd_encode_glyph( char c ){ int value = 0; if( c >= 'a' && c <= 'z' ) value = c-'a'+11; @@ -39,7 +40,7 @@ static f32 sfd_encode_glyph( char c ) return (float)value; } -VG_STATIC void sfd_encode( u32 row, const char *str ) +static void sfd_encode( u32 row, const char *str ) { int end=0; u32 row_h = world_sfd.h -1 -row; @@ -59,8 +60,55 @@ VG_STATIC void sfd_encode( u32 row, const char *str ) } } -VG_STATIC void sfd_update(void) -{ +static void world_sfd_update( world_instance *world, v3f pos ){ + if( mdl_arrcount( &world->ent_route ) ){ + u32 closest = 0; + float min_dist = INFINITY; + + for( u32 i=0; ient_route ); i++ ){ + ent_route *route = mdl_arritm( &world->ent_route, i ); + float dist = v3_dist2( route->board_transform[3], pos ); + + if( dist < min_dist ){ + min_dist = dist; + closest = i; + } + } + + if( (world_sfd.active_route_board != closest) || network_scores_updated ){ + network_scores_updated = 0; + world_sfd.active_route_board = closest; + ent_route *route = mdl_arritm( &world->ent_route, closest ); + + addon_reg *world_reg = world_static.addon_hub; + if( world_static.active_instance ) + world_reg = world_static.addon_client; + + char mod_uid[ ADDON_UID_MAX ]; + addon_alias_uid( &world_reg->alias, mod_uid ); + + network_request_scoreboard( + mod_uid, + mdl_pstr( &world->meta, route->pstr_name ), + 0 ); +#if 0 + u32 id = route->anon.official_track_id; + + if( id != 0xffffffff ){ + struct netmsg_board *local_board = + &scoreboard_client_data.boards[id]; + + for( int i=0; i<13; i++ ){ + sfd_encode( i, &local_board->data[27*i] ); + } + }else{ + sfd_encode( 0, mdl_pstr( &world->meta, route->pstr_name ) ); + sfd_encode( 1, "No data" ); + } +#endif + } + } + for( int i=0; i