Fixed bugs with team assignment
This commit is contained in:
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
Before Width: | Height: | Size: 102 KiB After Width: | Height: | Size: 101 KiB |
@@ -5,7 +5,6 @@ import com.badlogic.gdx.audio.Sound;
|
|||||||
import com.badlogic.gdx.graphics.Color;
|
import com.badlogic.gdx.graphics.Color;
|
||||||
import com.badlogic.gdx.utils.ObjectMap;
|
import com.badlogic.gdx.utils.ObjectMap;
|
||||||
import com.badlogic.gdx.utils.TimeUtils;
|
import com.badlogic.gdx.utils.TimeUtils;
|
||||||
import io.anuke.mindustry.Vars;
|
|
||||||
import io.anuke.mindustry.content.Mechs;
|
import io.anuke.mindustry.content.Mechs;
|
||||||
import io.anuke.mindustry.core.GameState.State;
|
import io.anuke.mindustry.core.GameState.State;
|
||||||
import io.anuke.mindustry.entities.Player;
|
import io.anuke.mindustry.entities.Player;
|
||||||
@@ -172,7 +171,7 @@ public class Control extends Module{
|
|||||||
players[0].isAdmin = true;
|
players[0].isAdmin = true;
|
||||||
}catch(IOException e){
|
}catch(IOException e){
|
||||||
ui.showError(Bundles.format("text.server.error", Strings.parseException(e, false)));
|
ui.showError(Bundles.format("text.server.error", Strings.parseException(e, false)));
|
||||||
state.set(State.menu);
|
threads.runDelay(() -> state.set(State.menu));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -202,6 +202,7 @@ public class NetServer extends Module{
|
|||||||
return Integer.MAX_VALUE;
|
return Integer.MAX_VALUE;
|
||||||
});
|
});
|
||||||
player.setTeam(min);
|
player.setTeam(min);
|
||||||
|
Log.info("Auto-assigned player {0} to team {1}.", player.name, player.getTeam());
|
||||||
}
|
}
|
||||||
|
|
||||||
connections.put(id, player);
|
connections.put(id, player);
|
||||||
|
|||||||
@@ -336,11 +336,13 @@ public class Renderer extends RendererModule{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resize(int width, int height){
|
public void resize(int width, int height){
|
||||||
|
float lastX = camera.position.x, lastY = camera.position.y;
|
||||||
super.resize(width, height);
|
super.resize(width, height);
|
||||||
for(Player player : players){
|
for(Player player : players){
|
||||||
control.input(player.playerIndex).resetCursor();
|
control.input(player.playerIndex).resetCursor();
|
||||||
}
|
}
|
||||||
camera.position.set(players[0].x, players[0].y, 0);
|
camera.update();
|
||||||
|
camera.position.set(lastX, lastY, 0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import com.badlogic.gdx.math.Vector2;
|
|||||||
import com.badlogic.gdx.utils.Queue;
|
import com.badlogic.gdx.utils.Queue;
|
||||||
import io.anuke.annotations.Annotations.Loc;
|
import io.anuke.annotations.Annotations.Loc;
|
||||||
import io.anuke.annotations.Annotations.Remote;
|
import io.anuke.annotations.Annotations.Remote;
|
||||||
import io.anuke.mindustry.Vars;
|
|
||||||
import io.anuke.mindustry.content.Mechs;
|
import io.anuke.mindustry.content.Mechs;
|
||||||
import io.anuke.mindustry.content.fx.UnitFx;
|
import io.anuke.mindustry.content.fx.UnitFx;
|
||||||
import io.anuke.mindustry.entities.effect.ScorchDecal;
|
import io.anuke.mindustry.entities.effect.ScorchDecal;
|
||||||
@@ -727,12 +726,14 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
|||||||
|
|
||||||
//region utility methods
|
//region utility methods
|
||||||
|
|
||||||
public void toggleTeam(){
|
|
||||||
team = (team == Team.blue ? Team.red : Team.blue);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Resets all values of the player.*/
|
/** Resets all values of the player.*/
|
||||||
public void reset(){
|
public void reset(){
|
||||||
|
resetNoAdd();
|
||||||
|
|
||||||
|
add();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void resetNoAdd(){
|
||||||
status.clear();
|
status.clear();
|
||||||
team = Team.blue;
|
team = Team.blue;
|
||||||
inventory.clear();
|
inventory.clear();
|
||||||
@@ -744,8 +745,6 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
|||||||
boostHeat = drownTime = hitTime = 0f;
|
boostHeat = drownTime = hitTime = 0f;
|
||||||
mech = (isMobile ? Mechs.starterMobile : Mechs.starterDesktop);
|
mech = (isMobile ? Mechs.starterMobile : Mechs.starterDesktop);
|
||||||
placeQueue.clear();
|
placeQueue.clear();
|
||||||
|
|
||||||
add();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isShooting(){
|
public boolean isShooting(){
|
||||||
|
|||||||
@@ -183,6 +183,7 @@ public class NetworkIO{
|
|||||||
|
|
||||||
Entities.clear();
|
Entities.clear();
|
||||||
int id = stream.readInt();
|
int id = stream.readInt();
|
||||||
|
player.resetNoAdd();
|
||||||
player.read(stream, TimeUtils.millis());
|
player.read(stream, TimeUtils.millis());
|
||||||
player.resetID(id);
|
player.resetID(id);
|
||||||
player.add();
|
player.add();
|
||||||
@@ -258,7 +259,6 @@ public class NetworkIO{
|
|||||||
i += consecutives;
|
i += consecutives;
|
||||||
}
|
}
|
||||||
|
|
||||||
player.reset();
|
|
||||||
state.teams = new Teams();
|
state.teams = new Teams();
|
||||||
|
|
||||||
byte teams = stream.readByte();
|
byte teams = stream.readByte();
|
||||||
|
|||||||
Reference in New Issue
Block a user