diff options
m--------- | common | 0 | ||||
-rw-r--r-- | game.cpp | 22 |
2 files changed, 6 insertions, 16 deletions
diff --git a/common b/common -Subproject 1f97ccdac792c0b5b07972e7d4b2f28416046ea +Subproject e483f468085379a986cbc48bb13a7983315475c @@ -40,7 +40,7 @@ void Game::run(const std::string host, const std::string port) { unsigned int last = SDL_GetTicks(); while(scene->running) { if(SDL_GetTicks() - last >= 1000) { - message::Pos pos(scene->pos.x, scene->pos.y, scene->pos.z); + message::Pos pos(scene->pos); pos.send(socket); last = SDL_GetTicks(); } @@ -88,13 +88,10 @@ void Game::handle_type(const boost::system::error_code& error, std::size_t bytes void Game::handle_chunk() { message::Chunk m; - // coords - m.read(socket); + m.recv(socket); int64_t x, y; m.get_coords(x, y); - // data - m.read(socket); float *data = m.get_data(); scene->terrain->tc->add_chunk(data, x, y, Terrain::chunk_size_total, Terrain::chunk_size_total); @@ -110,10 +107,7 @@ void Game::handle_chunk() { void Game::handle_message() { message::Message m; - m.read(socket); - m.get_len(); - - m.read(socket); + m.recv(socket); std::string s = m.get_str(); scene->chat->add_line(s); @@ -122,15 +116,11 @@ void Game::handle_message() { void Game::handle_player() { message::Player m; - m.read(socket); + m.recv(socket); + uint32_t id = m.get_id(); Vector3 pos(m.get_pos()); - m.get_len(); - - // fetching string - m.read(socket); - - std::string name = m.get_str(); + std::string name = m.get_name(); scene->players.push_back(Player::p(new Player(id, pos, name))); } |