mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-03-13 11:29:48 +07:00
Exploit fixes
This commit is contained in:
parent
effdaefdf3
commit
58be00b3ce
@ -80,8 +80,17 @@ public class NetServer extends Module{
|
||||
Net.handleServer(ConnectPacket.class, (id, packet) -> {
|
||||
String uuid = packet.uuid;
|
||||
|
||||
if(Net.getConnection(id) == null ||
|
||||
admins.isIPBanned(Net.getConnection(id).address)) return;
|
||||
NetConnection connection = Net.getConnection(id);
|
||||
|
||||
if(connection == null ||
|
||||
admins.isIPBanned(connection.address)) return;
|
||||
|
||||
if(connection.hasBegunConnecting){
|
||||
kick(id, KickReason.idInUse);
|
||||
return;
|
||||
}
|
||||
|
||||
connection.hasBegunConnecting = true;
|
||||
|
||||
TraceInfo trace = admins.getTraceByID(uuid);
|
||||
PlayerInfo info = admins.getInfo(uuid);
|
||||
@ -112,7 +121,7 @@ public class NetServer extends Module{
|
||||
return;
|
||||
}
|
||||
|
||||
if(player.uuid.equals(packet.uuid)){
|
||||
if(player.uuid.equals(packet.uuid) || player.usid.equals(packet.usid)){
|
||||
kick(id, KickReason.idInUse);
|
||||
return;
|
||||
}
|
||||
@ -182,7 +191,7 @@ public class NetServer extends Module{
|
||||
long elapsed = TimeUtils.timeSinceMillis(connection.lastRecievedClientTime);
|
||||
|
||||
float maxSpeed = packet.boosting && !player.mech.flying ? player.mech.boostSpeed : player.mech.speed;
|
||||
float maxMove = elapsed / 1000f * 60f * Math.min(compound(maxSpeed, player.mech.drag) * 1.1f, player.mech.maxSpeed * 1.05f);
|
||||
float maxMove = elapsed / 1000f * 60f * Math.min(compound(maxSpeed, player.mech.drag) * 1.2f, player.mech.maxSpeed * 1.05f);
|
||||
|
||||
player.pointerX = packet.pointerX;
|
||||
player.pointerY = packet.pointerY;
|
||||
@ -195,12 +204,16 @@ public class NetServer extends Module{
|
||||
}
|
||||
|
||||
vector.set(packet.x - player.getInterpolator().target.x, packet.y - player.getInterpolator().target.y);
|
||||
|
||||
vector.limit(maxMove);
|
||||
|
||||
float prevx = player.x, prevy = player.y;
|
||||
player.set(player.getInterpolator().target.x, player.getInterpolator().target.y);
|
||||
player.move(vector.x, vector.y);
|
||||
if(!player.mech.flying){
|
||||
player.move(vector.x, vector.y);
|
||||
}else{
|
||||
player.x += vector.x;
|
||||
player.y += vector.y;
|
||||
}
|
||||
float newx = player.x, newy = player.y;
|
||||
|
||||
if(!verifyPosition){
|
||||
@ -238,16 +251,14 @@ public class NetServer extends Module{
|
||||
|
||||
private float compound(float speed, float drag){
|
||||
float total = 0f;
|
||||
for(int i = 0; i < 10; i++){
|
||||
for(int i = 0; i < 20; i++){
|
||||
total *= (1f - drag);
|
||||
total += speed;
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a raw byte[] snapshot to a client, splitting up into chunks when needed.
|
||||
*/
|
||||
/** Sends a raw byte[] snapshot to a client, splitting up into chunks when needed.*/
|
||||
private static void sendSplitSnapshot(int userid, byte[] bytes, int snapshotID, int base){
|
||||
if(bytes.length < maxSnapshotSize){
|
||||
Call.onSnapshot(userid, bytes, snapshotID, (short) 0, bytes.length, base);
|
||||
@ -321,6 +332,8 @@ public class NetServer extends Module{
|
||||
|
||||
@Remote(targets = Loc.client)
|
||||
public static void connectConfirm(Player player){
|
||||
if(player.con == null || player.con.hasConnected) return;
|
||||
|
||||
player.add();
|
||||
player.con.hasConnected = true;
|
||||
Call.sendMessage("[accent]" + player.name + " [accent]has connected.");
|
||||
|
@ -9,7 +9,6 @@ import io.anuke.mindustry.content.Items;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.maps.generation.WorldGenerator.GenResult;
|
||||
import io.anuke.mindustry.maps.missions.BattleMission;
|
||||
import io.anuke.mindustry.maps.missions.WaveMission;
|
||||
import io.anuke.mindustry.world.ColorMapper;
|
||||
import io.anuke.mindustry.world.Edges;
|
||||
@ -135,13 +134,10 @@ public class Sectors{
|
||||
private void initSector(Sector sector){
|
||||
sector.difficulty = (int)(Mathf.dst(sector.x, sector.y)/2);
|
||||
|
||||
if(sector.difficulty < 1){
|
||||
sector.missions.add(new WaveMission(30));
|
||||
if(sector.difficulty == 0){
|
||||
sector.missions.add(new WaveMission(10));
|
||||
}else{
|
||||
sector.missions.add(Mathf.choose(
|
||||
new BattleMission(sector.difficulty),
|
||||
new WaveMission(30 + sector.difficulty*5 + Mathf.randomSeed(sector.getSeed(), 0, 5)*5)
|
||||
));
|
||||
sector.missions.add(new WaveMission(Math.min(10 + sector.difficulty*5 + Mathf.randomSeed(sector.getSeed(), 0, 5)*5, 100)));
|
||||
}
|
||||
|
||||
//add all ores for now since material differences aren't well handled yet
|
||||
|
@ -1,7 +1,6 @@
|
||||
package io.anuke.mindustry.maps.missions;
|
||||
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.content.blocks.StorageBlocks;
|
||||
import io.anuke.mindustry.game.GameMode;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.maps.Sector;
|
||||
@ -33,21 +32,8 @@ public class BattleMission implements Mission{
|
||||
|
||||
@Override
|
||||
public void generate(Tile[][] tiles, Sector sector){
|
||||
int cx = 0, cy = 0;
|
||||
outer:
|
||||
for(int x = 0; x < tiles.length; x++){
|
||||
for(int y = 0; y < tiles[0].length; y++){
|
||||
if(tiles[x][y].block() == StorageBlocks.core){
|
||||
//set enemy core position to mirrored player core position
|
||||
cx = tiles.length - 1 - x;
|
||||
cy = tiles[0].length - 1 - y;
|
||||
break outer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tiles[cx][cy].setBlock(StorageBlocks.core);
|
||||
tiles[cx][cy].setTeam(Team.red);
|
||||
generateCoreAt(tiles, 60, 60, Team.blue);
|
||||
generateCoreAt(tiles, tiles.length-1-60, tiles[0].length-1-60, Team.red);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,9 +1,16 @@
|
||||
package io.anuke.mindustry.maps.missions;
|
||||
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import io.anuke.mindustry.content.blocks.Blocks;
|
||||
import io.anuke.mindustry.content.blocks.StorageBlocks;
|
||||
import io.anuke.mindustry.game.GameMode;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.maps.Sector;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.blocks.Floor;
|
||||
import io.anuke.ucore.noise.Noise;
|
||||
import io.anuke.ucore.scene.ui.layout.Table;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
|
||||
public interface Mission{
|
||||
boolean isComplete();
|
||||
@ -12,4 +19,32 @@ public interface Mission{
|
||||
void display(Table table);
|
||||
|
||||
default void generate(Tile[][] tiles, Sector sector){}
|
||||
|
||||
default void generateCoreAt(Tile[][] tiles, int coreX, int coreY, Team team){
|
||||
Noise.setSeed(0);
|
||||
float targetElevation = Math.max(tiles[coreX][coreY].getElevation(), 1);
|
||||
|
||||
int lerpDst = 20;
|
||||
for(int x = -lerpDst; x <= lerpDst; x++){
|
||||
for(int y = -lerpDst; y <= lerpDst; y++){
|
||||
int wx = tiles.length/2 + x, wy = tiles[0].length/2 + y;
|
||||
|
||||
float dst = Vector2.dst(wx, wy, coreX, coreY);
|
||||
float elevation = tiles[wx][wy].getElevation();
|
||||
|
||||
if(dst < lerpDst){
|
||||
elevation = Mathf.lerp(elevation, targetElevation, Mathf.clamp(2*(1f-(dst / lerpDst))) + Noise.nnoise(wx, wy, 8f, 1f));
|
||||
}
|
||||
|
||||
if(tiles[wx][wy].floor().liquidDrop == null){
|
||||
tiles[wx][wy].setElevation((int) elevation);
|
||||
}else{
|
||||
tiles[wx][wy].setFloor((Floor) Blocks.sand);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tiles[coreX][coreY].setBlock(StorageBlocks.core);
|
||||
tiles[coreX][coreY].setTeam(team);
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +1,11 @@
|
||||
package io.anuke.mindustry.maps.missions;
|
||||
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import io.anuke.mindustry.content.blocks.Blocks;
|
||||
import io.anuke.mindustry.content.blocks.StorageBlocks;
|
||||
import io.anuke.mindustry.game.GameMode;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.maps.Sector;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.blocks.Floor;
|
||||
import io.anuke.ucore.noise.Noise;
|
||||
import io.anuke.ucore.scene.ui.layout.Table;
|
||||
import io.anuke.ucore.util.Bundles;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
|
||||
import static io.anuke.mindustry.Vars.state;
|
||||
|
||||
@ -24,32 +18,8 @@ public class WaveMission implements Mission{
|
||||
|
||||
@Override
|
||||
public void generate(Tile[][] tiles, Sector sector){
|
||||
Noise.setSeed(0);
|
||||
int coreX = tiles.length/2, coreY = tiles.length/2;
|
||||
float targetElevation = Math.max(tiles[coreX][coreY].getElevation(), 1);
|
||||
|
||||
int lerpDst = 20;
|
||||
for(int x = -lerpDst; x <= lerpDst; x++){
|
||||
for(int y = -lerpDst; y <= lerpDst; y++){
|
||||
int wx = tiles.length/2 + x, wy = tiles[0].length/2 + y;
|
||||
|
||||
float dst = Vector2.dst(wx, wy, coreX, coreY);
|
||||
float elevation = tiles[wx][wy].getElevation();
|
||||
|
||||
if(dst < lerpDst){
|
||||
elevation = Mathf.lerp(elevation, targetElevation, Mathf.clamp(2*(1f-(dst / lerpDst))) + Noise.nnoise(wx, wy, 8f, 1f));
|
||||
}
|
||||
|
||||
if(tiles[wx][wy].floor().liquidDrop == null){
|
||||
tiles[wx][wy].setElevation((int) elevation);
|
||||
}else{
|
||||
tiles[wx][wy].setFloor((Floor) Blocks.sand);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tiles[coreX][coreY].setBlock(StorageBlocks.core);
|
||||
tiles[coreX][coreY].setTeam(Team.blue);
|
||||
generateCoreAt(tiles, coreX, coreY, Team.blue);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -31,6 +31,7 @@ public abstract class NetConnection{
|
||||
public long lastRecievedClientTime;
|
||||
|
||||
public boolean hasConnected = false;
|
||||
public boolean hasBegunConnecting = false;
|
||||
|
||||
public NetConnection(int id, String address){
|
||||
this.id = id;
|
||||
|
@ -4,12 +4,10 @@ import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.files.FileHandle;
|
||||
import io.anuke.mindustry.entities.Player;
|
||||
import io.anuke.mindustry.entities.TileEntity;
|
||||
import io.anuke.mindustry.entities.effect.ItemDrop;
|
||||
import io.anuke.mindustry.entities.units.BaseUnit;
|
||||
import io.anuke.mindustry.entities.units.UnitType;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
import io.anuke.mindustry.type.Item;
|
||||
import io.anuke.mindustry.ui.dialogs.FloatingDialog;
|
||||
import io.anuke.mindustry.ui.dialogs.GenViewDialog;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
@ -20,7 +18,6 @@ import io.anuke.ucore.scene.ui.Label;
|
||||
import io.anuke.ucore.scene.ui.layout.Table;
|
||||
import io.anuke.ucore.util.Log;
|
||||
import io.anuke.ucore.util.Log.LogHandler;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
@ -128,12 +125,6 @@ public class DebugFragment extends Fragment{
|
||||
t.row();
|
||||
t.addButton("noclip", "toggle", () -> noclip = !noclip);
|
||||
t.row();
|
||||
t.addButton("items", () -> {
|
||||
for(int i = 0; i < 10; i++){
|
||||
ItemDrop.create(Item.all().random(), 5, player.x, player.y, Mathf.random(360f));
|
||||
}
|
||||
});
|
||||
t.row();
|
||||
t.addButton("team", "toggle", player::toggleTeam);
|
||||
t.row();
|
||||
t.addButton("blocks", "toggle", () -> showBlockDebug = !showBlockDebug);
|
||||
|
Loading…
Reference in New Issue
Block a user