From: hgn Date: Sun, 1 Oct 2023 06:17:18 +0000 (+0100) Subject: board pose X-Git-Url: https://harrygodden.com/git/?a=commitdiff_plain;h=9385ff1868a052d92d60c0b49aa03848460b1916;p=carveJwlIkooP6JGAAIwe30JlM.git board pose --- diff --git a/gameserver.c b/gameserver.c index 00c39f3..6965eea 100644 --- a/gameserver.c +++ b/gameserver.c @@ -348,7 +348,7 @@ static void gameserver_rx_200_300( SteamNetworkingMessage_t *msg ){ prop->inetmsg_id = k_inetmsg_playerusername; prop->index = client_id; - u32 chs = vg_strncpy( client->username, prop->name, name_len, + u32 chs = vg_strncpy( client->username, prop->name, NETWORK_USERNAME_MAX, k_strncpy_always_add_null ); vg_info( "client #%d changed name to: %s [%s]\n", client_id, @@ -367,14 +367,32 @@ static void gameserver_rx_200_300( SteamNetworkingMessage_t *msg ){ k_nSteamNetworkingSend_Unreliable ); } else if( tmp->inetmsg_id == k_inetmsg_playeritem ){ - netmsg_playeritem *item = alloca(msg->m_cbSize); - memcpy( item, msg->m_pData, msg->m_cbSize ); - item->client = client_id; + netmsg_playeritem *item = msg->m_pData; - vg_info( "Client #%u equiped: [%u] %s\n", - item->client, item->type, item->uid ); + /* record */ + struct gameserver_client *client = &gameserver.clients[ client_id ]; - gameserver_send_to_all( client_id, item, msg->m_cbSize, + if( item->type == k_addon_type_board ){ + network_msgstring( item->uid, msg->m_cbSize, sizeof(netmsg_playeritem), + client->item_board, ADDON_UID_MAX ); + } + else if( item->type == k_addon_type_player ){ + network_msgstring( item->uid, msg->m_cbSize, sizeof(netmsg_playeritem), + client->item_player, ADDON_UID_MAX ); + } + else { + vg_warn( "Client #%d invalid equip type %u\n", + client_id, (u32)item->type ); + return; + } + vg_info( "Client #%d equiped: [%u] %s\n", + item->client, item->type, item->uid ); + + /* propogate */ + netmsg_playeritem *prop = alloca(msg->m_cbSize); + memcpy( prop, msg->m_pData, msg->m_cbSize ); + prop->client = client_id; + gameserver_send_to_all( client_id, prop, msg->m_cbSize, k_nSteamNetworkingSend_Reliable ); } } diff --git a/gameserver.h b/gameserver.h index 26099a6..646457e 100644 --- a/gameserver.h +++ b/gameserver.h @@ -24,7 +24,7 @@ struct { char item_board[ ADDON_UID_MAX ], item_player[ ADDON_UID_MAX ]; } - clients[ 32 ]; + clients[ NETWORK_MAX_PLAYERS ]; u8 app_symmetric_key[ k_nSteamEncryptedAppTicketSymmetricKeyLen ]; diff --git a/network_common.h b/network_common.h index 59d08bd..988afb2 100644 --- a/network_common.h +++ b/network_common.h @@ -5,6 +5,7 @@ #include "vg/vg_platform.h" #define NETWORK_USERNAME_MAX 32 +#define NETWORK_MAX_PLAYERS 20 #include "addon_types.h" diff --git a/player_remote.c b/player_remote.c index 6b66656..1689063 100644 --- a/player_remote.c +++ b/player_remote.c @@ -31,13 +31,6 @@ static void player_remote_rx_200_300( SteamNetworkingMessage_t *msg ){ /* TODO: interpret the uids */ player->board_view_slot = 0; player->playermodel_view_slot = 0; -#if 0 - addon_cache_create_viewer_from_uid( k_addon_type_board, - playerjoin->board_uid ); - player->playermodel_view_slot = - addon_cache_create_viewer_from_uid( k_addon_type_player, - playerjoin->playermodel_uid ); -#endif struct interp_buffer *buf = &netplayers.interp_data[playerjoin->index]; buf->t = -99999999.9; @@ -307,6 +300,7 @@ static void pose_remote_player( u32 index, struct player_avatar *av = localplayer.playeravatar; struct skeleton *sk = &localplayer.playeravatar->sk; m4x3f *final_mtx = &netplayers.final_mtx[ av->sk.bone_count*index ]; + struct player_board_pose *board_pose = &netplayers.board_poses[index]; struct player_subsystem_interface *sys0 = player_subsystems[f0->subsystem], *sys1 = NULL; @@ -324,9 +318,11 @@ static void pose_remote_player( u32 index, lerp_player_pose( &pose0, &pose1, t, &posed ); apply_full_skeleton_pose( &av->sk, &posed, final_mtx ); + memcpy( board_pose, &posed.board, sizeof(*board_pose) ); } else { apply_full_skeleton_pose( &av->sk, &pose0, final_mtx ); + memcpy( board_pose, &pose0.board, sizeof(*board_pose) ); } } @@ -401,7 +397,7 @@ static void render_remote_players( world_instance *world, camera *cam ){ SDL_AtomicLock( &addon_system.sl_cache_using_resources ); - for( u32 i=0; iactive ) continue; @@ -418,14 +414,10 @@ static void render_remote_players( world_instance *world, camera *cam ){ struct player_board *board = addon_cache_item_if_loaded( k_addon_type_board, player->board_view_slot ); - - /* TODO: Board pose */ -#if 0 render_board( cam, world, board, final_mtx[localplayer.playeravatar->id_board], - &localplayer.pose.board, + &netplayers.board_poses[ i ], k_board_shader_player ); -#endif } SDL_AtomicUnlock( &addon_system.sl_cache_using_resources ); diff --git a/player_remote.h b/player_remote.h index ca96290..6cf7ce5 100644 --- a/player_remote.h +++ b/player_remote.h @@ -3,6 +3,7 @@ #include "player.h" #include "network.h" +#include "network_common.h" struct { struct network_player { @@ -14,7 +15,7 @@ struct { u32 down_bytes; f32 down_kbs; } - list[32]; + list[ NETWORK_MAX_PLAYERS ]; struct interp_buffer { /* collect the most recent 6 frames of animation data */ @@ -34,9 +35,10 @@ struct { f64 t; } - interp_data[32]; + interp_data[ NETWORK_MAX_PLAYERS ]; m4x3f *final_mtx; + struct player_board_pose board_poses[ NETWORK_MAX_PLAYERS ]; u32 up_bytes; f32 up_kbs, down_kbs; diff --git a/skaterift.c b/skaterift.c index f089f79..b5029c4 100644 --- a/skaterift.c +++ b/skaterift.c @@ -205,7 +205,8 @@ static void vg_load(void){ /* FIXME FIXME FIXME FIXME FIXME */ u32 mtx_size = sizeof(m4x3f)*localplayer_avatar.sk.bone_count; localplayer.final_mtx = vg_linear_alloc( vg_mem.rtmemory, mtx_size ); - netplayers.final_mtx = vg_linear_alloc( vg_mem.rtmemory, mtx_size*32 ); + netplayers.final_mtx = vg_linear_alloc( vg_mem.rtmemory, + mtx_size*NETWORK_MAX_PLAYERS ); player_model_load( &localplayer.fallback_model, "models/ch_none.mdl" ); player__bind();