Skip to content

Commit

Permalink
Merge pull request #169 from konstructs/fix-network-bug
Browse files Browse the repository at this point in the history
Only do game logic when connected
  • Loading branch information
nsg committed Mar 25, 2016
2 parents e08a1c9 + f2a6d02 commit 6eebeec
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,30 +198,30 @@ class Konstructs: public nanogui::Screen {
if (client.is_connected()) {
handle_network();
handle_keys();
handle_mouse();
looking_at = player.looking_at(world, blocks);
glClear(GL_DEPTH_BUFFER_BIT);
for(auto model : model_factory.fetch_models()) {
chunk_shader.add(model);
}
sky_shader.render(player, mSize.x(), mSize.y(), time_of_day());
glClear(GL_DEPTH_BUFFER_BIT);
int faces = chunk_shader.render(player, mSize.x(), mSize.y(),
daylight(), time_of_day(), world, client);
player_shader->render(player, mSize.x(), mSize.y(),
daylight(), time_of_day());
if(looking_at && !hud.get_interactive() && !menu_state) {
selection_shader.render(player, mSize.x(), mSize.y(),
looking_at->second.position);
}
//cout << "Faces: " << faces << " FPS: " << fps.fps << endl;
glClear(GL_DEPTH_BUFFER_BIT);
if(!hud.get_interactive() && !menu_state)
crosshair_shader.render(mSize.x(), mSize.y());
double mx, my;
glfwGetCursorPos(mGLFWWindow, &mx, &my);
hud_shader.render(mSize.x(), mSize.y(), mx, my, hud, blocks);
}
handle_mouse();
looking_at = player.looking_at(world, blocks);
glClear(GL_DEPTH_BUFFER_BIT);
for(auto model : model_factory.fetch_models()) {
chunk_shader.add(model);
}
sky_shader.render(player, mSize.x(), mSize.y(), time_of_day());
glClear(GL_DEPTH_BUFFER_BIT);
int faces = chunk_shader.render(player, mSize.x(), mSize.y(),
daylight(), time_of_day(), world, client);
player_shader->render(player, mSize.x(), mSize.y(),
daylight(), time_of_day());
if(looking_at && !hud.get_interactive() && !menu_state) {
selection_shader.render(player, mSize.x(), mSize.y(),
looking_at->second.position);
}
//cout << "Faces: " << faces << " FPS: " << fps.fps << endl;
glClear(GL_DEPTH_BUFFER_BIT);
if(!hud.get_interactive() && !menu_state)
crosshair_shader.render(mSize.x(), mSize.y());
double mx, my;
glfwGetCursorPos(mGLFWWindow, &mx, &my);
hud_shader.render(mSize.x(), mSize.y(), mx, my, hud, blocks);
}

private:
Expand Down

0 comments on commit 6eebeec

Please sign in to comment.