commit 6c09e8fd7c6f34789433e936fa6da11b68ebbbed parent 24b44a173d678bdad588a55f495d57d7af4668b9 Author: Michael Savage <mikejsavage@gmail.com> Date: Mon Jul 10 23:53:37 +0300 Fix server sending malformed updates Diffstat:
hm.cc | | | 2 | +- |
server/main.cc | | | 7 | +------ |
diff --git a/hm.cc b/hm.cc @@ -354,7 +354,7 @@ GAME_FRAME( game_frame ) { player->pos = pos; } else if( player_state == 1 ) { - ggprint( "{08} disconnected\n", player->sid ); + ggprint( "{08x} disconnected\n", player->sid ); players.release( player ); } } diff --git a/server/main.cc b/server/main.cc @@ -183,8 +183,7 @@ int main() { char write_buf[ 1400 ]; WriteStream w( write_buf ); - - void * player_count_storage = reserve_u16( &w ); + write_u16( &w, states.elems.n ); for( size_t i = 0; i < states.elems.n; i++ ) { PlayerState * state = &states.elems[ i ]; @@ -201,10 +200,6 @@ int main() { } } - // TODO: endianness - u16 player_count = states.elems.n; - memcpy( player_count_storage, &player_count, sizeof( player_count ) ); - if( w.ok ) { for( const PlayerState & state : states.elems ) { send( server_fd_ipv4, &state, w );