257 if let Some(ref info) = r.game_info { |
257 if let Some(ref info) = r.game_info { |
258 v.push(RunGame.send_self().action()); |
258 v.push(RunGame.send_self().action()); |
259 v.push(ClientFlags("+g".to_string(), vec![c.nick.clone()]) |
259 v.push(ClientFlags("+g".to_string(), vec![c.nick.clone()]) |
260 .send_all().in_room(r.id).action()); |
260 .send_all().in_room(r.id).action()); |
261 v.push(ForwardEngineMessage( |
261 v.push(ForwardEngineMessage( |
262 to_engine_msg("e$spectate 1".bytes()) + &info.msg_log) |
262 vec![to_engine_msg("e$spectate 1".bytes())]) |
|
263 .send_self().action()); |
|
264 v.push(ForwardEngineMessage(info.msg_log.clone()) |
263 .send_self().action()); |
265 .send_self().action()); |
264 |
266 |
265 for name in team_names.iter() { |
267 for name in team_names.iter() { |
266 v.push(ForwardEngineMessage( |
268 v.push(ForwardEngineMessage( |
267 to_engine_msg(once(b'G').chain(name.bytes()))) |
269 vec![to_engine_msg(once(b'G').chain(name.bytes()))]) |
268 .send_all().in_room(r.id).action()); |
270 .send_all().in_room(r.id).action()); |
269 } |
271 } |
270 if info.is_paused { |
272 if info.is_paused { |
271 v.push(ForwardEngineMessage(to_engine_msg(once(b'I'))) |
273 v.push(ForwardEngineMessage(vec![to_engine_msg(once(b'I'))]) |
272 .send_all().in_room(r.id).action()) |
274 .send_all().in_room(r.id).action()) |
273 } |
275 } |
274 } |
276 } |
275 } |
277 } |
276 v |
278 v |
435 SendTeamRemovalMessage(team_name) => { |
437 SendTeamRemovalMessage(team_name) => { |
436 let mut actions = Vec::new(); |
438 let mut actions = Vec::new(); |
437 if let (c, Some(r)) = server.client_and_room(client_id) { |
439 if let (c, Some(r)) = server.client_and_room(client_id) { |
438 if let Some(ref mut info) = r.game_info { |
440 if let Some(ref mut info) = r.game_info { |
439 let msg = once(b'F').chain(team_name.bytes()); |
441 let msg = once(b'F').chain(team_name.bytes()); |
440 actions.push(ForwardEngineMessage(to_engine_msg(msg)). |
442 actions.push(ForwardEngineMessage(vec![to_engine_msg(msg)]). |
441 send_all().in_room(r.id).but_self().action()); |
443 send_all().in_room(r.id).but_self().action()); |
442 info.teams_in_game -= 1; |
444 info.teams_in_game -= 1; |
443 if info.teams_in_game == 0 { |
445 if info.teams_in_game == 0 { |
444 actions.push(FinishRoomGame(r.id)); |
446 actions.push(FinishRoomGame(r.id)); |
445 } |
447 } |
446 let remove_msg = to_engine_msg(once(b'F').chain(team_name.bytes())); |
448 let remove_msg = to_engine_msg(once(b'F').chain(team_name.bytes())); |
447 match &info.last_msg { |
449 match &info.last_msg { |
448 Some(m) => info.msg_log.push_str(&m), |
450 Some(m) => info.msg_log.push(m.clone()), |
449 None => info.msg_log.push_str(&remove_msg) |
451 None => info.msg_log.push(remove_msg.clone()) |
450 } |
452 } |
451 actions.push(ForwardEngineMessage(remove_msg) |
453 actions.push(ForwardEngineMessage(vec![remove_msg]) |
452 .send_all().in_room(r.id).but_self().action()); |
454 .send_all().in_room(r.id).but_self().action()); |
453 } |
455 } |
454 } |
456 } |
455 server.react(client_id, actions); |
457 server.react(client_id, actions); |
456 } |
458 } |