mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-02-05 08:27:37 +07:00
Bugfixes
This commit is contained in:
parent
bae88ec416
commit
014e2ac8b8
Binary file not shown.
@ -84,7 +84,7 @@ public class Control implements ApplicationListener{
|
||||
});
|
||||
|
||||
Events.on(PlayEvent.class, event -> {
|
||||
player.setTeam(state.rules.pvp ? netServer.assignTeam(playerGroup.all()) : defaultTeam);
|
||||
player.setTeam(state.rules.pvp ? netServer.assignTeam(player, playerGroup.all()) : defaultTeam);
|
||||
player.setDead(true);
|
||||
player.add();
|
||||
|
||||
|
@ -176,7 +176,7 @@ public class NetServer implements ApplicationListener{
|
||||
|
||||
//playing in pvp mode automatically assigns players to teams
|
||||
if(state.rules.pvp){
|
||||
player.setTeam(assignTeam(playerGroup.all()));
|
||||
player.setTeam(assignTeam(player, playerGroup.all()));
|
||||
Log.info("Auto-assigned player {0} to team {1}.", player.name, player.getTeam());
|
||||
}
|
||||
|
||||
@ -194,13 +194,13 @@ public class NetServer implements ApplicationListener{
|
||||
});
|
||||
}
|
||||
|
||||
public Team assignTeam(Iterable<Player> players){
|
||||
public Team assignTeam(Player current, Iterable<Player> players){
|
||||
//find team with minimum amount of players and auto-assign player to that.
|
||||
return Structs.findMin(Team.all, team -> {
|
||||
if(state.teams.isActive(team) && !state.teams.get(team).cores.isEmpty()){
|
||||
int count = 0;
|
||||
for(Player other : players){
|
||||
if(other.getTeam() == team){
|
||||
if(other.getTeam() == team && other != current){
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
@ -700,10 +700,11 @@ public class ServerControl implements ApplicationListener{
|
||||
run.run();
|
||||
logic.play();
|
||||
state.rules = world.getMap().applyRules(lastMode);
|
||||
|
||||
for(Player p : players){
|
||||
p.reset();
|
||||
if(state.rules.pvp){
|
||||
p.setTeam(netServer.assignTeam(new ArrayIterable<>(players)));
|
||||
p.setTeam(netServer.assignTeam(p, new ArrayIterable<>(players)));
|
||||
}
|
||||
netServer.sendWorldData(p, p.con.id);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user