summaryrefslogtreecommitdiff
path: root/game.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'game.cpp')
-rw-r--r--game.cpp22
1 files changed, 6 insertions, 16 deletions
diff --git a/game.cpp b/game.cpp
index 3f4216d..d198720 100644
--- a/game.cpp
+++ b/game.cpp
@@ -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)));
}