#include "player.h"
#include "network.h"
#include "network_msg.h"
+#include "network_common.h"
#include "player_remote.h"
static void scores_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 );
}