Skip to content

Commit

Permalink
Send over killer data as well
Browse files Browse the repository at this point in the history
Bump version to 0.1.1
  • Loading branch information
nabijaczleweli committed Apr 23, 2016
1 parent feee8f7 commit 1df4b65
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ repository = "https://github.com/LoungeCPP/Tatsoryk/tree/master/server"
readme = "README.md"
keywords = ["game", "lounge", "server"]
license = "MIT"
version = "0.1.0"
version = "0.1.1"
# Remember to also modify options.rs authors
authors = ["nabijaczleweli <[email protected]>",
"Cat Plus Plus <[email protected]>",
Expand Down
17 changes: 9 additions & 8 deletions server/src/server/gamestate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,22 +140,19 @@ impl GameState {
if distance_between(bullet.bullet.x, bullet.bullet.y, player.x, player.y) <
BULLET_RADIUS + PLAYER_RADIUS {
destroyed_bullets.push(bullet.bullet.id);
destroyed_players.push(player.id);
destroyed_players.push((player.id, bullet.bullet.id));
}
}
}

// Process destroy requests
for bullet_id in destroyed_bullets {
let _ = self.bullets.remove(&bullet_id);
}

let mut rng = thread_rng();
for player_id in destroyed_players {
for (player_id, bullet_id) in destroyed_players {
let bullet = self.bullets.get(&bullet_id).unwrap();
self.send_to_everybody(message::Message::PlayerDestroyed {
id: player_id,
killer_id: None,
bullet_id: None,
killer_id: Some(bullet.owner_id),
bullet_id: Some(bullet_id),
});

let (new_x, new_y) = self.random_free_spot(&mut rng);
Expand All @@ -172,6 +169,10 @@ impl GameState {
y: new_y,
});
}

for bullet_id in destroyed_bullets {
let _ = self.bullets.remove(&bullet_id);
}
}

/// Send the current state to each client.
Expand Down

0 comments on commit 1df4b65

Please sign in to comment.