X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=player_remote.c;h=6358daa94afe2df6fa3c992a6571a714c6d531bb;hb=2179a91415c4d0726fd134ad942acfc0515844eb;hp=8cbbed6eed8cab2983f47c48c940b37dd93205e9;hpb=4f3f29420a3ae0253a195b9ca9a8ca7db67f0a7c;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/player_remote.c b/player_remote.c index 8cbbed6..6358daa 100644 --- a/player_remote.c +++ b/player_remote.c @@ -3,6 +3,10 @@ #include "player_render.h" #include "network_common.h" #include "addon.h" +#include "font.h" +#include "gui.h" + +static i32 k_show_own_name = 0; static void player_remote_clear( struct network_player *player ){ addon_cache_unwatch( k_addon_type_player, player->playermodel_view_slot ); @@ -20,24 +24,24 @@ static void player_remote_clear( struct network_player *player ){ static void relink_remote_player_worlds( u32 client_id ){ struct network_player *player = &netplayers.list[client_id]; - player->hub_match = 0; - player->client_match = 0; - - addon_alias q0,q1; - addon_uid_to_alias( player->items[k_netmsg_playeritem_world0], &q0 ); - addon_uid_to_alias( player->items[k_netmsg_playeritem_world1], &q1 ); + addon_alias q[2]; + addon_uid_to_alias( player->items[k_netmsg_playeritem_world0], &q[0] ); + addon_uid_to_alias( player->items[k_netmsg_playeritem_world1], &q[1] ); /* * currently in 10.23, the hub world will always be the same. * this might but probably wont change in the future */ - if( world_static.addon_hub ) - if( addon_alias_eq( &q0, &world_static.addon_hub->alias ) ) - player->hub_match = 1; + for( u32 i=0; ialias ) ) - player->client_match = 1; + player->world_match[i] = 0; + + if( reg ){ + if( addon_alias_eq( &q[i], &world_static.instance_addons[i]->alias ) ) + player->world_match[i] = 1; + } + } } /* @@ -54,6 +58,14 @@ static void relink_all_remote_player_worlds(void){ } } +static void player_remote_update_friendflags( struct network_player *remote ){ + ISteamFriends *hSteamFriends = SteamAPI_SteamFriends(); + remote->isfriend = SteamAPI_ISteamFriends_HasFriend( hSteamFriends, + remote->steamid, k_EFriendFlagImmediate ); + remote->isblocked = SteamAPI_ISteamFriends_HasFriend( hSteamFriends, + remote->steamid, k_EFriendFlagBlocked ); +} + static void player_remote_rx_200_300( SteamNetworkingMessage_t *msg ){ netmsg_blank *tmp = msg->m_pData; @@ -65,6 +77,8 @@ static void player_remote_rx_200_300( SteamNetworkingMessage_t *msg ){ struct network_player *player = &netplayers.list[ playerjoin->index ]; player_remote_clear( player ); player->active = 1; + player->steamid = playerjoin->steamid; + player_remote_update_friendflags( player ); /* TODO: interpret the uids */ player->board_view_slot = 0; @@ -76,7 +90,8 @@ static void player_remote_rx_200_300( SteamNetworkingMessage_t *msg ){ buf->frames[i].active = 0; } - vg_info( "#%u joined\n", playerjoin->index ); + vg_info( "#%u joined friend: %d, blocked: %d\n", + playerjoin->index, player->isfriend, player->isblocked ); } else { vg_error( "inetmsg_playerjoin: player index out of range\n" ); @@ -341,6 +356,7 @@ 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 ); @@ -496,16 +512,8 @@ static void pose_remote_player( u32 index, memcpy( board_pose, &pose0.board, sizeof(*board_pose) ); } - if( instance_id ){ - if( player->client_match ){ - player->active_world = &world_static.instances[ instance_id ]; - } - } - else{ - if( player->hub_match ){ - player->active_world = &world_static.instances[ instance_id ]; - } - } + if( player->world_match[ instance_id ] ) + player->active_world = &world_static.instances[ instance_id ]; } /* @@ -579,12 +587,11 @@ 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 || player->isblocked ) continue; if( player->active_world != world ) continue; struct player_avatar *av = localplayer.playeravatar; @@ -609,7 +616,54 @@ static void render_remote_players( world_instance *world, camera *cam ){ SDL_AtomicUnlock( &addon_system.sl_cache_using_resources ); } +static void render_remote_player_nametag( v3f co, const char *name ){ + m4x3f mlocal; + m4x3_identity( mlocal ); + mlocal[3][0] -= font3d_string_width( 2, name ) * 0.5f; + + m4x3f mmdl; + m3x3_identity( mmdl ); + for( int i=0; i<3; i++ ) + v3_muls( skaterift.cam.mtx.v[i], 0.2f, mmdl[i] ); + m3x3_transpose( mmdl, mmdl ); + v3_add( co, (v3f){0.0f,2.0f,0.0f}, mmdl[3] ); + + m4x3_mul( mmdl, mlocal, mmdl ); + font3d_simple_draw( 2, name, &skaterift.cam, mmdl ); +} + +static void render_remote_players_tags( world_instance *world, camera *cam ){ + glEnable(GL_BLEND); + glEnable(GL_DEPTH_TEST); + glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); + glBlendEquation(GL_FUNC_ADD); + + font3d_bind( &gui.font, k_font_shader_default, 1, NULL, &skaterift.cam ); + font3d_setcolour( (v4f){1.0f,1.0f,1.0f,1.0f} ); + + if( k_show_own_name ){ + render_remote_player_nametag( + localplayer.final_mtx[0][3], + steam_username_at_startup ); + } + + for( u32 i=0; iactive || player->isblocked ) 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){ + vg_console_reg_var( "k_show_own_name", &k_show_own_name, + k_var_dtype_i32, 0 ); for( u32 i=0; iactive || !player->isfriend ) continue; + + ui_rect box = { x, y, width, height }; + remote_player_gui_info( box, player->username, "", 0, 0 ); + y += height + gap; + } +}