Browse Source

Only updates lines when changed

master
Joshua Moerman 12 years ago
parent
commit
a4ef07ef3f
  1. 3
      src/app.h
  2. 1
      src/basics.h
  3. 3
      src/main.cpp

3
src/app.h

@ -94,6 +94,9 @@ struct App{
for(auto & l : line.calculate_lines()){
sim.lines.push_back(l);
}
for(auto & u : people_online){
u->update_lines = true;
}
}
void login(User& user){

1
src/basics.h

@ -28,6 +28,7 @@ struct User {
unsigned int index{0};
std::string name{"Unknown guest"};
bool update_lines{true};
Size size{0,0};
Position position{0,0};

3
src/main.cpp

@ -31,7 +31,10 @@ websockets::TestProtocol<User> default_protocol{
[](User& user, basic_websocket_info) -> std::string{
js::Object ret;
ret["balls"] = vector_to_json(app->sim.balls);
if(user.update_lines){
ret["lines"] = vector_to_json(app->sim.lines);
user.update_lines = false;
}
return write_json(ret);
},
// receive