X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=player_remote.c;h=b533d389e5af955ea6bc8dd9b0aa76d7c79cb604;hb=4eb81766e4e7c54599b057ebf57b7fab01cd0726;hp=3e78d506488a3f7603c71d5b2d7b3a7c2851cc55;hpb=ce0205fd929e5fb1446f8c52fcab344884d82569;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/player_remote.c b/player_remote.c index 3e78d50..b533d38 100644 --- a/player_remote.c +++ b/player_remote.c @@ -3,6 +3,8 @@ #include "player_render.h" #include "network_common.h" #include "addon.h" +#include "font.h" +#include "gui.h" static void player_remote_clear( struct network_player *player ){ addon_cache_unwatch( k_addon_type_player, player->playermodel_view_slot ); @@ -166,10 +168,33 @@ static void player_remote_rx_200_300( SteamNetworkingMessage_t *msg ){ * -------------------------------------------------------------*/ for( u32 i=0; isound_effects; i ++ ){ - /* CHEATING for now */ struct net_sfx sfx; net_sfx_exchange( &ctx, &sfx ); - net_sfx_play( &sfx ); + + f64 t = (frame->timestamp - NETWORK_FRAMERATE) + + (sfx.subframe*NETWORK_FRAMERATE); + + f32 remaining = t - ib->t; + + if( remaining <= 0.0f ) + net_sfx_play( &sfx ); + else{ + struct net_sfx *dst = NULL; + + for( u32 j=0; jsystem == k_player_subsystem_invalid ){ + dst = sj; + break; + } + + if( sj->priority < sfx.priority ) + dst = sj; + } + + *dst = sfx; + dst->subframe = remaining; + } } /* animation @@ -317,6 +342,32 @@ static void remote_player_debug_update(void){ } } +static void remote_player_nametag( m4x4f pv, v3f co, const char *name ){ + return; + vg_ui.font = &vg_ui_font_big; + v4f wpos; + v3_copy( co, wpos ); + wpos[1] += 2.0f; + wpos[3] = 1.0f; + + m4x4_mulv( pv, wpos, wpos ); + + if( wpos[3] > 0.0f ){ + v2_muls( wpos, (1.0f/wpos[3]) * 0.5f, wpos ); + v2_add( wpos, (v2f){ 0.5f, 0.5f }, wpos ); + + ui_rect wr; + wr[0] = vg_clampf(wpos[0] * vg.window_x, -32000.0f,32000.0f)-150; + wr[1] = vg_clampf((1.0f-wpos[1]) * vg.window_y, + -32000.0f,32000.0f); + wr[2] = 300; + wr[3] = 32; + ui_fill( wr, (ui_colour(k_ui_bg)&0x00ffffff)|0x50000000 ); + ui_text( wr, name, 1, k_ui_align_middle_center, 0 ); + } + vg_ui.font = &vg_ui_font_small; +} + /* * Debugging information */ @@ -377,30 +428,23 @@ static void remote_player_network_imgui( m4x4f pv ){ i, player->username, sysname, player->down_kbs ); ui_info( panel, buf ); - v4f wpos = { 0.0f, 2.0f, 0.0f, 1.0f }; struct player_avatar *av = localplayer.playeravatar; - m4x3_mulv( netplayers.final_mtx[av->sk.bone_count*i], wpos, wpos ); - m4x4_mulv( pv, wpos, wpos ); - - if( wpos[3] > 0.0f ){ - v2_muls( wpos, (1.0f/wpos[3]) * 0.5f, wpos ); - v2_add( wpos, (v2f){ 0.5f, 0.5f }, wpos ); - - ui_rect wr; - wr[0] = vg_clampf(wpos[0] * vg.window_x, -32000.0f,32000.0f)-150; - wr[1] = vg_clampf((1.0f-wpos[1]) * vg.window_y, - -32000.0f,32000.0f); - wr[2] = 300; - wr[3] = 17; - ui_fill( wr, (ui_colour(k_ui_bg)&0x00ffffff)|0x50000000 ); - ui_text( wr, buf, 1, k_ui_align_middle_center, 0 ); - } + remote_player_nametag( + pv, + netplayers.final_mtx[av->sk.bone_count*i][3], + player->username ); } } } else { ui_info( panel, "offline" ); } + + struct player_avatar *av = localplayer.playeravatar; + remote_player_nametag( + pv, + localplayer.final_mtx[0][3], + "Localplayer" ); } /* @@ -538,7 +582,6 @@ static void animate_remote_players(void){ * Draw remote players */ static void render_remote_players( world_instance *world, camera *cam ){ - SDL_AtomicLock( &addon_system.sl_cache_using_resources ); for( u32 i=0; iactive ) continue; + if( player->active_world != world ) continue; + + struct player_avatar *av = localplayer.playeravatar; + render_remote_player_nametag( + netplayers.final_mtx[av->sk.bone_count*i][3], + player->username ); + } + + glDisable(GL_BLEND); +} + +static void remote_players_init(void){ + for( u32 i=0; isystem != k_player_subsystem_invalid ){ + si->subframe -= vg.time_frame_delta; + if( si->subframe <= 0.0f ){ + net_sfx_play( si ); + si->system = k_player_subsystem_invalid; + } + } + } +}