X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=network.c;h=53ebd4bc0bf63ed0e17dfae9e21f806db0e3f411;hb=825c3bce18272c0f81659e0eac469709d0462836;hp=3235c697e84ee7359a9d9a3bd4c739fdd082d2a6;hpb=5ecddf16ae658b5f526d8d370a63223cf141a592;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/network.c b/network.c index 3235c69..53ebd4b 100644 --- a/network.c +++ b/network.c @@ -1,6 +1,7 @@ #include "player.h" #include "network.h" #include "network_msg.h" +#include "network_common.h" #include "player_remote.h" static void scores_update(void); @@ -131,18 +132,18 @@ static void server_routine_update(void){ #endif static void network_send_username(void){ - netmsg_playerusername update; - memset( &update, 0, sizeof(update) ); - update.inetmsg_id = k_inetmsg_playerusername; - update.index = 0xffffffff; + netmsg_playerusername *update = alloca( sizeof(netmsg_playerusername)+ + NETWORK_USERNAME_MAX ); + update->inetmsg_id = k_inetmsg_playerusername; + update->index = 0xffffffff; ISteamFriends *hSteamFriends = SteamAPI_SteamFriends(); const char *username = SteamAPI_ISteamFriends_GetPersonaName(hSteamFriends); - str_utf8_collapse( username, update.username, sizeof(update.username) ); + u32 chs = str_utf8_collapse( username, update->name, NETWORK_USERNAME_MAX ); SteamAPI_ISteamNetworkingSockets_SendMessageToConnection( hSteamNetworkingSockets, network_client.remote, - &update, sizeof(update), + update, sizeof(netmsg_playerusername)+chs+1, k_nSteamNetworkingSend_Reliable, NULL ); }