Merge branch 'master' of https://github.com/Anuken/Mindustry into mechs-balance-altfire

# Conflicts:
#	core/src/io/anuke/mindustry/world/blocks/storage/CoreBlock.java
This commit is contained in:
Anuken
2018-08-24 08:57:19 -04:00
19 changed files with 166 additions and 102 deletions

View File

@@ -127,24 +127,22 @@ project(":ios") {
apply plugin: "robovm" apply plugin: "robovm"
task copyGen{ task copyGen{
doFirst{ copy{
copy{ from ("core/build/classes/java/main/io/anuke/mindustry/gen/"){
from ("../core/build/classes/java/main/io/anuke/mindustry/gen/"){ include "**/*.java"
include "**/*.java"
}
into "../core/src/io/anuke/mindustry/gen"
} }
into "ios/src/io/anuke/mindustry/gen"
} }
doLast{ doFirst{
delete{ delete{
delete "../core/src/io/anuke/mindustry/gen/" delete "ios/src/io/anuke/mindustry/gen/"
} }
} }
} }
build.finalizedBy(copyGen) build.dependsOn(copyGen)
dependencies { dependencies {
compile project(":core") compile project(":core")

View File

@@ -375,14 +375,14 @@ content.unit-type.name=Боевые единицы
content.recipe.name=Блоки content.recipe.name=Блоки
item.stone.name=Камень item.stone.name=Камень
item.stone.description=Обычное сырьё. Используется для разделения и переработки в другие материалы или плавления в лаву. item.stone.description=Обычное сырьё. Используется для разделения и переработки в другие материалы или плавления в лаву.
item.tungsten.name=Вольфрам item.copper.name=Медь
item.tungsten.description=Обычный, но очень полезный строительный материал . Используется в бурах и теплостойких блоках, таких как генераторы и плавильные печи. item.copper.description=Полезный строительный материал. Широко используется во всех типах блоков.
item.lead.name=Свинец item.lead.name=Свинец
item.lead.description=Основной начальный материал. Широко используется в блоках электроники и транспортировки жидкости. item.lead.description=Основной начальный материал. Широко используется в блоках электроники и транспортировки жидкости.
item.coal.name=Уголь item.coal.name=Уголь
item.coal.description=Распространённое и легкодоступное топливо. item.coal.description=Распространённое и легкодоступное топливо.
item.carbide.name=Карбид item.dense-alloy.name=Плотный сплав
item.carbide.description=Жёсткий сплав, изготовленный из вольфрама и угля. Используется в передовых транспортных блоках и высокоуровневых бурах. item.dense-alloy.description=Жёсткий сплав, изготовленный из свинца и меди. Используется в передовых транспортных блоках и высокоуровневых бурах.
item.titanium.name=Титан item.titanium.name=Титан
item.titanium.description=Редкий сверхлёгкий металл широко используется в транспортировке, бурах и самолётах. item.titanium.description=Редкий сверхлёгкий металл широко используется в транспортировке, бурах и самолётах.
item.thorium.name=Торий item.thorium.name=Торий
@@ -430,10 +430,12 @@ block.shrub.name=Куст
block.rock.name=Булыжник block.rock.name=Булыжник
block.blackrock.name=Чёрный булыжник block.blackrock.name=Чёрный булыжник
block.icerock.name=Ледяной булыжник block.icerock.name=Ледяной булыжник
block.tungsten-wall.name=Вольфрамовая стена block.copper-wall.name=Медная стена
block.tungsten-wall-large.name=Большая вольфрамовая стена block.copper-wall-large.name=Большая медная стена
block.carbide-wall.name=Карбидная стена block.composite-wall.name=Композитная стена
block.carbide-wall-large.name=Большая карбидная стена block.composite-wall-large.name=Большая композитная стена
block.phase-wall.name=Фазовая стена
block.phase-wall-large.name=Большая фазовая стена
block.thorium-wall.name=Ториевая стена block.thorium-wall.name=Ториевая стена
block.thorium-wall-large.name=Большая ториевая стена block.thorium-wall-large.name=Большая ториевая стена
block.door.name=Дверь block.door.name=Дверь
@@ -474,8 +476,8 @@ block.battery.name=Аккумулятор
block.battery-large.name=Большой аккумулятор block.battery-large.name=Большой аккумулятор
block.combustion-generator.name=Генератор внутреннего сгорания block.combustion-generator.name=Генератор внутреннего сгорания
block.turbine-generator.name=Турбинный генератор block.turbine-generator.name=Турбинный генератор
block.tungsten-drill.name=Вольфрамовый бур block.mechanical-drill.name=Механический бур
block.carbide-drill.name=Карбидовый бур block.pneumatic-drill.name=Пневматический бур
block.laser-drill.name=Лазерный бур block.laser-drill.name=Лазерный бур
block.water-extractor.name=Экстрактор воды block.water-extractor.name=Экстрактор воды
block.cultivator.name=Культиватор block.cultivator.name=Культиватор
@@ -525,7 +527,7 @@ block.liquid-tank.name=Жидкостный резервуар
block.liquid-junction.name=Жидкостный перекрёсток block.liquid-junction.name=Жидкостный перекрёсток
block.bridge-conduit.name=Мостовой трубопровод block.bridge-conduit.name=Мостовой трубопровод
block.rotary-pump.name=Роторный насос block.rotary-pump.name=Роторный насос
block.nuclear-reactor.name=Ядерный реактор block.thorium-reactor.name=Ториевый реактор
block.command-center.name=Командный центр block.command-center.name=Командный центр
block.mass-driver.name=Электромагнитная катапульта block.mass-driver.name=Электромагнитная катапульта
block.blast-drill.name=Буровая установка block.blast-drill.name=Буровая установка

View File

@@ -375,14 +375,14 @@ content.unit-type.name=Бойові одиниці
content.recipe.name=Блоки content.recipe.name=Блоки
item.stone.name=Камінь item.stone.name=Камінь
item.stone.description=Загальна сировина. Використовується для розділення та переробки в інші матеріали або плавки в лаву. item.stone.description=Загальна сировина. Використовується для розділення та переробки в інші матеріали або плавки в лаву.
item.tungsten.name=Вольфрам item.copper.name=Мідь
item.tungsten.description=Звичайний, але дуже корисний структурнй матеріал. Використовується в свердлах та термостійких блоках, таких як генератори та плавильні. item.copper.description=Корисний структурний матеріал. Широко використовується у всіх типах блоків.
item.lead.name=Свинець item.lead.name=Свинець
item.lead.description=Базовий стартовий матеріал. Широко використовується в блоках електроніки та транспорту рідини. item.lead.description=Базовий стартовий матеріал. Широко використовується в блоках електроніки та транспорту рідини.
item.coal.name=Вугілля item.coal.name=Вугілля
item.coal.description=Загальне та легкодоступне паливо. item.coal.description=Загальне та легкодоступне паливо.
item.carbide.name=Карбід item.dense-alloy.name=Щільний сплав
item.carbide.description=Жорсткий сплав з вольфрамом та карбідом. Використовується в передових транспортних блоках та високорівневих свердлах. item.dense-alloy.description=Жорсткий сплав з свинцем та міддю. Використовується в передових транспортних блоках та високорівневих свердлах.
item.titanium.name=Титан item.titanium.name=Титан
item.titanium.description=Рідкий суперлегкий метал широко використовується в рідкому транспорті, свердлах та літальних апаратах. item.titanium.description=Рідкий суперлегкий метал широко використовується в рідкому транспорті, свердлах та літальних апаратах.
item.thorium.name=Торій item.thorium.name=Торій
@@ -430,10 +430,12 @@ block.shrub.name=кущ
block.rock.name=кругляк block.rock.name=кругляк
block.blackrock.name=чорний-кругляк block.blackrock.name=чорний-кругляк
block.icerock.name=льодяний-кругляк block.icerock.name=льодяний-кругляк
block.tungsten-wall.name=Вольфрамова стіна block.copper-wall.name=Мідна стіна
block.tungsten-wall-large.name=Велика вольфрамова стіна block.copper-wall-large.name=Велика мідна стіна
block.carbide-wall.name=Карбідна стіна block.composite-wall.name=Композитна стіна
block.carbide-wall-large.name=Велика карбідна стіна block.composite-wall-large.name=Велика композитна стіна
block.phase-wall.name=Композитна стінка
block.phase-wall-large.name=Велика фазова стіна
block.thorium-wall.name=Торієва стіна block.thorium-wall.name=Торієва стіна
block.thorium-wall-large.name=Велика Торієва стіна block.thorium-wall-large.name=Велика Торієва стіна
block.door.name=Двері block.door.name=Двері
@@ -474,8 +476,8 @@ block.battery.name=Акумулятор
block.battery-large.name=Великий акумулятор block.battery-large.name=Великий акумулятор
block.combustion-generator.name=Генератор горіння block.combustion-generator.name=Генератор горіння
block.turbine-generator.name=Турбогенератор block.turbine-generator.name=Турбогенератор
block.tungsten-drill.name=Вольфрамовий дриль block.mechanical-drill.name=Механічний дриль
block.carbide-drill.name=Карбідовий дриль block.pneumatic-drill.name=Пневматичний дриль
block.laser-drill.name=Лазерний дриль block.laser-drill.name=Лазерний дриль
block.water-extractor.name=Екстрактор води block.water-extractor.name=Екстрактор води
block.cultivator.name=Культиватор block.cultivator.name=Культиватор
@@ -525,7 +527,7 @@ block.liquid-tank.name=Рідкий резервуар
block.liquid-junction.name=Рідкий з'єднання block.liquid-junction.name=Рідкий з'єднання
block.bridge-conduit.name=Мостовий водопровід block.bridge-conduit.name=Мостовий водопровід
block.rotary-pump.name=Роторний насос block.rotary-pump.name=Роторний насос
block.nuclear-reactor.name=Ядерний реактор block.thorium-reactor.name=Торієвий реактор
block.command-center.name=Командний центр block.command-center.name=Командний центр
block.mass-driver.name=Електромагнітна катапульта block.mass-driver.name=Електромагнітна катапульта
block.blast-drill.name=Бурова установка block.blast-drill.name=Бурова установка

View File

@@ -28,12 +28,10 @@ import io.anuke.ucore.util.Translator;
import java.util.Locale; import java.util.Locale;
public class Vars{ public class Vars{
//respawn time in frames
public static final float respawnduration = 60 * 4;
//time between waves in frames (on normal mode) //time between waves in frames (on normal mode)
public static final float wavespace = 60 * 60 * 1.5f; public static final float wavespace = 60 * 60 * 1.5f;
//set ridiculously high for now //set ridiculously high for now
public static final float coreBuildRange = 800999f; public static final float coreBuildRange = 999999f;
//team of the player by default //team of the player by default
public static final Team defaultTeam = Team.blue; public static final Team defaultTeam = Team.blue;
//team of the enemy in waves //team of the enemy in waves

View File

@@ -352,7 +352,7 @@ public class Control extends Module{
throw new RuntimeException(error); throw new RuntimeException(error);
} }
if(Inputs.keyTap("console")){ if(debug && Inputs.keyTap("console")){
console = !console; console = !console;
} }

View File

@@ -66,8 +66,6 @@ public class Logic extends Module{
} }
} }
Events.fire(PlayEvent.class); Events.fire(PlayEvent.class);
} }

View File

@@ -80,18 +80,8 @@ public class NetClient extends Module{
player.isAdmin = false; player.isAdmin = false;
Net.setClientLoaded(false); reset();
removed.clear();
timeoutTime = 0f;
connecting = true;
quiet = false;
lastSent = 0;
lastSnapshotBase = null;
currentSnapshot = null;
currentSnapshotID = -1;
lastSnapshotBaseID = -1;
ui.chatfrag.clearMessages();
ui.loadfrag.hide(); ui.loadfrag.hide();
ui.loadfrag.show("$text.connecting.data"); ui.loadfrag.show("$text.connecting.data");
@@ -102,8 +92,6 @@ public class NetClient extends Module{
Net.disconnect(); Net.disconnect();
}); });
Entities.clear();
ConnectPacket c = new ConnectPacket(); ConnectPacket c = new ConnectPacket();
c.name = player.name; c.name = player.name;
c.mobile = mobile; c.mobile = mobile;
@@ -161,6 +149,29 @@ public class NetClient extends Module{
ui.loadfrag.hide(); ui.loadfrag.hide();
} }
@Remote(variants = Variant.both)
public static void onInfoMessage(String message){
threads.runGraphics(() -> ui.showText("", message));
}
@Remote(variants = Variant.both)
public static void onWorldDataBegin(){
Entities.clear();
ui.chatfrag.clearMessages();
Net.setClientLoaded(false);
threads.runGraphics(() -> {
ui.loadfrag.show("$text.connecting.data");
ui.loadfrag.setButton(() -> {
ui.loadfrag.hide();
netClient.connecting = false;
netClient.quiet = true;
Net.disconnect();
});
});
}
@Remote(variants = Variant.one) @Remote(variants = Variant.one)
public static void onPositionSet(float x, float y){ public static void onPositionSet(float x, float y){
players[0].x = x; players[0].x = x;
@@ -285,7 +296,6 @@ public class NetClient extends Module{
//go through each entity //go through each entity
for(int j = 0; j < amount; j++){ for(int j = 0; j < amount; j++){
int position = netClient.byteStream.position(); //save position to check read/write correctness
int id = input.readInt(); int id = input.readInt();
byte typeID = input.readByte(); byte typeID = input.readByte();
@@ -304,11 +314,6 @@ public class NetClient extends Module{
//read the entity //read the entity
entity.read(input, timestamp); entity.read(input, timestamp);
byte readLength = input.readByte();
//if(netClient.byteStream.position() - position - 1 != readLength){
// throw new RuntimeException("Error reading entity of type '" + group.getType() + "': Read length mismatch [write=" + readLength + ", read=" + (netClient.byteStream.position() - position - 1) + "]");
//}
if(add){ if(add){
entity.add(); entity.add();
netClient.addRemovedEntity(entity.getID()); netClient.addRemovedEntity(entity.getID());
@@ -352,6 +357,22 @@ public class NetClient extends Module{
Timers.runTask(40f, Platform.instance::updateRPC); Timers.runTask(40f, Platform.instance::updateRPC);
} }
private void reset(){
Net.setClientLoaded(false);
removed.clear();
timeoutTime = 0f;
connecting = true;
quiet = false;
lastSent = 0;
lastSnapshotBase = null;
currentSnapshot = null;
currentSnapshotID = -1;
lastSnapshotBaseID = -1;
Entities.clear();
ui.chatfrag.clearMessages();
}
public void beginConnecting(){ public void beginConnecting(){
connecting = true; connecting = true;
} }

View File

@@ -190,15 +190,7 @@ public class NetServer extends Module{
trace.playerid = player.id; trace.playerid = player.id;
//TODO try DeflaterOutputStream sendWorldData(player, id);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
DeflaterOutputStream def = new DeflaterOutputStream(stream);
NetworkIO.writeWorld(player, def);
WorldStream data = new WorldStream();
data.stream = new ByteArrayInputStream(stream.toByteArray());
Net.sendStream(id, data);
Log.info("Packed {0} uncompressed bytes of WORLD data.", stream.size());
Platform.instance.updateRPC(); Platform.instance.updateRPC();
}); });
@@ -317,6 +309,17 @@ public class NetServer extends Module{
} }
} }
public void sendWorldData(Player player, int clientID){
ByteArrayOutputStream stream = new ByteArrayOutputStream();
DeflaterOutputStream def = new DeflaterOutputStream(stream);
NetworkIO.writeWorld(player, def);
WorldStream data = new WorldStream();
data.stream = new ByteArrayInputStream(stream.toByteArray());
Net.sendStream(clientID, data);
Log.info("Packed {0} compressed bytes of world data.", stream.size());
}
public static void onDisconnect(Player player){ public static void onDisconnect(Player player){
if(player.con.hasConnected){ if(player.con.hasConnected){
Call.sendMessage("[accent]" + player.name + "[accent] has disconnected."); Call.sendMessage("[accent]" + player.name + "[accent] has disconnected.");
@@ -483,7 +486,6 @@ public class NetServer extends Module{
int length = syncStream.position() - position; //length must always be less than 127 bytes int length = syncStream.position() - position; //length must always be less than 127 bytes
if(length > 127) if(length > 127)
throw new RuntimeException("Write size for entity of type " + group.getType() + " must not exceed 127!"); throw new RuntimeException("Write size for entity of type " + group.getType() + " must not exceed 127!");
dataStream.writeByte(length);
} }
} }
} }

View File

@@ -702,7 +702,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
dead = true; dead = true;
trail.clear(); trail.clear();
health = maxHealth(); health = maxHealth();
mech = (mobile ? Mechs.starterMobile : Mechs.starterDesktop); mech = (isMobile ? Mechs.starterMobile : Mechs.starterDesktop);
placeQueue.clear(); placeQueue.clear();
add(); add();

View File

@@ -320,7 +320,7 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
if(target != null) behavior(); if(target != null) behavior();
if(!isWave){ if(!isWave && !isFlying()){
x = Mathf.clamp(x, 0, world.width() * tilesize); x = Mathf.clamp(x, 0, world.width() * tilesize);
y = Mathf.clamp(y, 0, world.height() * tilesize); y = Mathf.clamp(y, 0, world.height() * tilesize);
} }

View File

@@ -21,10 +21,12 @@ public enum GameMode{
isPvp = true; isPvp = true;
hidden = true; hidden = true;
enemyCoreBuildRadius = 600f; enemyCoreBuildRadius = 600f;
respawnTime = 60 * 10;
}}; }};
public boolean infiniteResources, disableWaveTimer, disableWaves, hidden, autoSpawn, isPvp; public boolean infiniteResources, disableWaveTimer, disableWaves, hidden, autoSpawn, isPvp;
public float enemyCoreBuildRadius = 400f; public float enemyCoreBuildRadius = 400f;
public float respawnTime = 60 * 4;
public String description(){ public String description(){
return Bundles.get("mode." + name() + ".description"); return Bundles.get("mode." + name() + ".description");

View File

@@ -248,7 +248,7 @@ public class WorldGenerator{
double iceridge = rid.getValue(x+99999, y, 1f / 300f) + sim3.octaveNoise2D(2, 1f, 1f/14f, x, y)/11f; double iceridge = rid.getValue(x+99999, y, 1f / 300f) + sim3.octaveNoise2D(2, 1f, 1f/14f, x, y)/11f;
double elevation = elevationOf(x, y, detailed); double elevation = elevationOf(x, y, detailed);
double temp = vn.noise(x, y, 1f / 300f) * sim3.octaveNoise2D(detailed ? 2 : 1, 1, 1f / 13f, x, y)/13f double temp = vn.noise(x, y, 1f / 300f) * sim3.octaveNoise2D(detailed ? 2 : 1, 1, 1f / 13f, x, y)/13f
+ sim3.octaveNoise2D(detailed ? 12 : 6, 0.6, 1f / 920f, x, y); + sim3.octaveNoise2D(detailed ? 12 : 9, 0.6, 1f / 920f, x, y);
int lerpDst = 20; int lerpDst = 20;
lerpDst *= lerpDst; lerpDst *= lerpDst;
@@ -272,6 +272,10 @@ public class WorldGenerator{
floor = Blocks.water; floor = Blocks.water;
}else if(elevation < 0.85){ }else if(elevation < 0.85){
floor = Blocks.sand; floor = Blocks.sand;
}else if(temp < 0.42){
floor = Blocks.snow;
}else if(temp < 0.5){
floor = Blocks.stone;
}else if(temp < 0.55){ }else if(temp < 0.55){
floor = Blocks.grass; floor = Blocks.grass;
}else if(temp < 0.6){ }else if(temp < 0.6){
@@ -288,14 +292,6 @@ public class WorldGenerator{
floor = Blocks.blackstone; floor = Blocks.blackstone;
} }
if(temp < 0.6f){
if(elevation > 3){
floor = Blocks.snow;
}else if(elevation > 2.5){
floor = Blocks.stone;
}
}
if(elevation > 3.3 && iceridge > 0.25 && temp < 0.6f){ if(elevation > 3.3 && iceridge > 0.25 && temp < 0.6f){
elevation ++; elevation ++;
floor = Blocks.ice; floor = Blocks.ice;
@@ -317,7 +313,7 @@ public class WorldGenerator{
double elevationOf(int x, int y, boolean detailed){ double elevationOf(int x, int y, boolean detailed){
double ridge = rid.getValue(x, y, 1f / 400f); double ridge = rid.getValue(x, y, 1f / 400f);
return sim.octaveNoise2D(detailed ? 7 : 2, 0.62, 1f / 640, x, y) * 6.1 - 1 - ridge; return sim.octaveNoise2D(detailed ? 7 : 4, 0.62, 1f / 640, x, y) * 6.1 - 1 - ridge;
} }
public static class GenResult{ public static class GenResult{

View File

@@ -118,6 +118,8 @@ public class NetworkIO{
i += consecutives; i += consecutives;
} }
stream.write(Team.all.length);
//write team data //write team data
for(Team team : Team.all){ for(Team team : Team.all){
TeamData data = state.teams.get(team); TeamData data = state.teams.get(team);

View File

@@ -14,7 +14,7 @@ public class ItemImage extends Stack{
public ItemImage(TextureRegion region, Supplier<CharSequence> text){ public ItemImage(TextureRegion region, Supplier<CharSequence> text){
Table t = new Table().left().bottom(); Table t = new Table().left().bottom();
t.label(text).color(Color.DARK_GRAY).padBottom(-22).get().setFontScale(Unit.dp.scl(0.5f)); t.label(text).color(Color.DARK_GRAY).padBottom(-21).get().setFontScale(Unit.dp.scl(0.5f));
t.row(); t.row();
t.label(text).get().setFontScale(Unit.dp.scl(0.5f)); t.label(text).get().setFontScale(Unit.dp.scl(0.5f));
@@ -25,7 +25,7 @@ public class ItemImage extends Stack{
public ItemImage(ItemStack stack){ public ItemImage(ItemStack stack){
Table t = new Table().left().bottom(); Table t = new Table().left().bottom();
t.add(stack.amount + "").color(Color.DARK_GRAY).padBottom(-22).get().setFontScale(Unit.dp.scl(0.5f)); t.add(stack.amount + "").color(Color.DARK_GRAY).padBottom(-21).get().setFontScale(Unit.dp.scl(0.5f));
t.row(); t.row();
t.add(stack.amount + "").get().setFontScale(Unit.dp.scl(0.5f)); t.add(stack.amount + "").get().setFontScale(Unit.dp.scl(0.5f));

View File

@@ -181,7 +181,7 @@ public class CoreBlock extends StorageBlock{
if(entity.currentUnit != null){ if(entity.currentUnit != null){
entity.heat = Mathf.lerpDelta(entity.heat, 1f, 0.1f); entity.heat = Mathf.lerpDelta(entity.heat, 1f, 0.1f);
entity.time += Timers.delta(); entity.time += Timers.delta();
entity.progress += 1f / (entity.currentUnit instanceof Player ? respawnduration : droneRespawnDuration) * Timers.delta(); entity.progress += 1f / (entity.currentUnit instanceof Player ? state.mode.respawnTime : droneRespawnDuration) * Timers.delta();
//instant build for fast testing. //instant build for fast testing.
if(debug){ if(debug){

View File

@@ -43,7 +43,7 @@ public class ConsumeLiquid extends Consume{
@Override @Override
public boolean valid(Block block, TileEntity entity){ public boolean valid(Block block, TileEntity entity){
return entity.liquids.get(liquid) >= use(block); return entity != null && entity.liquids != null && entity.liquids.get(liquid) >= use(block);
} }
@Override @Override

View File

@@ -119,7 +119,7 @@ public class DesktopPlatform extends Platform{
@Override @Override
public boolean isDebug(){ public boolean isDebug(){
//honestly I'm just putting this ridiculous """anti-debug""" mess here to see if anyone bothers solving it without editing source //honestly I'm just putting this ridiculous """anti-debug""" mess here to see if anyone bothers solving it without editing source
return args.length > 0 && args[0].equals(("-debug_" + getUUID().hashCode() + "_" return args.length > 0 && args[0].equals(("-debug_" + "12312333_"
+ " " + System.getProperty("os.arch") + "nice" + (int)(Math.sin(System.getProperty("user.dir").hashCode()) * 100) + Thread.currentThread().getStackTrace()[1].toString()).hashCode() + "") && new File("../../desktop/build/").exists(); + " " + System.getProperty("os.arch") + "nice" + (int)(Math.sin(System.getProperty("user.dir").hashCode()) * 100) + Thread.currentThread().getStackTrace()[1].toString()).hashCode() + "") && new File("../../desktop/build/").exists();
} }
@@ -133,8 +133,7 @@ public class DesktopPlatform extends Platform{
try{ try{
Enumeration<NetworkInterface> e = NetworkInterface.getNetworkInterfaces(); Enumeration<NetworkInterface> e = NetworkInterface.getNetworkInterfaces();
NetworkInterface out; NetworkInterface out;
for(out = e.nextElement(); out.getHardwareAddress() == null && e.hasMoreElements() && validAddress(out.getHardwareAddress()); out = e.nextElement()) for(out = e.nextElement(); out.getHardwareAddress() == null && e.hasMoreElements() && validAddress(out.getHardwareAddress()); out = e.nextElement()) ;
;
byte[] bytes = out.getHardwareAddress(); byte[] bytes = out.getHardwareAddress();
byte[] result = new byte[8]; byte[] result = new byte[8];
@@ -151,6 +150,7 @@ public class DesktopPlatform extends Platform{
} }
private boolean validAddress(byte[] bytes){ private boolean validAddress(byte[] bytes){
if(bytes == null) return false;
byte[] result = new byte[8]; byte[] result = new byte[8];
System.arraycopy(bytes, 0, result, 0, bytes.length); System.arraycopy(bytes, 0, result, 0, bytes.length);
return !new String(Base64Coder.encode(result)).equals("AAAAAAAAAOA="); return !new String(Base64Coder.encode(result)).equals("AAAAAAAAAOA=");

View File

@@ -2,5 +2,5 @@ app.version=4.0
app.id=io.anuke.mindustry app.id=io.anuke.mindustry
app.mainclass=io.anuke.mindustry.IOSLauncher app.mainclass=io.anuke.mindustry.IOSLauncher
app.executable=IOSLauncher app.executable=IOSLauncher
app.build=20 app.build=22
app.name=Mindustry app.name=Mindustry

View File

@@ -9,13 +9,16 @@ import io.anuke.mindustry.game.Difficulty;
import io.anuke.mindustry.game.EventType.GameOverEvent; import io.anuke.mindustry.game.EventType.GameOverEvent;
import io.anuke.mindustry.game.GameMode; import io.anuke.mindustry.game.GameMode;
import io.anuke.mindustry.game.Team; import io.anuke.mindustry.game.Team;
import io.anuke.mindustry.gen.Call;
import io.anuke.mindustry.maps.Map;
import io.anuke.mindustry.io.SaveIO;
import io.anuke.mindustry.game.Version; import io.anuke.mindustry.game.Version;
import io.anuke.mindustry.net.*; import io.anuke.mindustry.gen.Call;
import io.anuke.mindustry.io.SaveIO;
import io.anuke.mindustry.maps.Map;
import io.anuke.mindustry.net.Administration;
import io.anuke.mindustry.net.Administration.PlayerInfo; import io.anuke.mindustry.net.Administration.PlayerInfo;
import io.anuke.mindustry.net.EditLog;
import io.anuke.mindustry.net.Net;
import io.anuke.mindustry.net.Packets.KickReason; import io.anuke.mindustry.net.Packets.KickReason;
import io.anuke.mindustry.net.TraceInfo;
import io.anuke.mindustry.type.Item; import io.anuke.mindustry.type.Item;
import io.anuke.mindustry.type.ItemType; import io.anuke.mindustry.type.ItemType;
import io.anuke.mindustry.ui.fragments.DebugFragment; import io.anuke.mindustry.ui.fragments.DebugFragment;
@@ -36,10 +39,12 @@ import static io.anuke.mindustry.Vars.*;
import static io.anuke.ucore.util.Log.*; import static io.anuke.ucore.util.Log.*;
public class ServerControl extends Module{ public class ServerControl extends Module{
private static final int roundExtraTime = 12;
private final CommandHandler handler = new CommandHandler(""); private final CommandHandler handler = new CommandHandler("");
private ShuffleMode mode; private ShuffleMode mode;
//consecutive sector losses
private int gameOvers; private int gameOvers;
private boolean inExtraRound;
public ServerControl(String[] args){ public ServerControl(String[] args){
Settings.defaultList( Settings.defaultList(
@@ -86,8 +91,8 @@ public class ServerControl extends Module{
} }
Events.on(GameOverEvent.class, () -> { Events.on(GameOverEvent.class, () -> {
if(inExtraRound) return;
info("Game over!"); info("Game over!");
netServer.kickAll(KickReason.gameover);
if(mode != ShuffleMode.off){ if(mode != ShuffleMode.off){
if(world.getSector() == null){ if(world.getSector() == null){
@@ -101,13 +106,18 @@ public class ServerControl extends Module{
while(map == previous) map = maps.random(); while(map == previous) map = maps.random();
} }
Call.onInfoMessage("[SCARLET]Game over![]\nNext selected map:[accent] "+map.name+"[]"
+ (map.meta.author() != null ? " by[accent] " + map.meta.author() + "[]" : "") + "."+
"\nNew game begins in " + roundExtraTime + " seconds.");
info("Selected next map to be {0}.", map.name); info("Selected next map to be {0}.", map.name);
logic.reset(); Map fmap = map;
world.loadMap(map);
state.set(State.playing); play(true, () -> world.loadMap(fmap));
} }
}else{ }else{
Call.onInfoMessage("Sector has been lost.\nRe-deploying in " + roundExtraTime + " seconds.");
if(gameOvers >= 2){ if(gameOvers >= 2){
Settings.putInt("sector_y", Settings.getInt("sector_y") < 0 ? Settings.getInt("sector_y") + 1 : Settings.getInt("sector_y") - 1); Settings.putInt("sector_y", Settings.getInt("sector_y") < 0 ? Settings.getInt("sector_y") + 1 : Settings.getInt("sector_y") - 1);
Settings.save(); Settings.save();
@@ -118,6 +128,7 @@ public class ServerControl extends Module{
info("Re-trying sector map: {0} {1}", Settings.getInt("sector_x"), Settings.getInt("sector_y")); info("Re-trying sector map: {0} {1}", Settings.getInt("sector_x"), Settings.getInt("sector_y"));
} }
}else{ }else{
netServer.kickAll(KickReason.gameover);
state.set(State.menu); state.set(State.menu);
Net.closeServer(); Net.closeServer();
} }
@@ -193,7 +204,7 @@ public class ServerControl extends Module{
}else{ }else{
Log.info("&ly&fiNo map specified. Loading sector {0}, {1}.", Settings.getInt("sector_x"), Settings.getInt("sector_y")); Log.info("&ly&fiNo map specified. Loading sector {0}, {1}.", Settings.getInt("sector_x"), Settings.getInt("sector_y"));
playSectorMap(); playSectorMap(false);
} }
info("Map loaded."); info("Map loaded.");
@@ -841,12 +852,44 @@ public class ServerControl extends Module{
} }
private void playSectorMap(){ private void playSectorMap(){
playSectorMap(true);
}
private void playSectorMap(boolean wait){
int x = Settings.getInt("sector_x"), y = Settings.getInt("sector_y"); int x = Settings.getInt("sector_x"), y = Settings.getInt("sector_y");
if(world.sectors().get(x, y) == null){ if(world.sectors().get(x, y) == null){
world.sectors().createSector(x, y); world.sectors().createSector(x, y);
} }
world.loadSector(world.sectors().get(x, y));
logic.play(); world.sectors().get(x, y).completedMissions = 0;
play(wait, () -> world.loadSector(world.sectors().get(x, y)));
}
private void play(boolean wait, Runnable run){
inExtraRound = true;
Runnable r = () -> {
Array<Player> players = new Array<>();
for(Player p : playerGroup.all()){
players.add(p);
p.setDead(true);
}
logic.reset();
Call.onWorldDataBegin();
run.run();
logic.play();
for(Player p : players){
p.reset();
netServer.sendWorldData(p, p.con.id);
}
inExtraRound = false;
};
if(wait){
Timers.runTask(60f * roundExtraTime, r);
}else{
r.run();
}
} }
private void host(){ private void host(){
@@ -864,15 +907,15 @@ public class ServerControl extends Module{
if(state.is(State.playing) && world.getSector() != null){ if(state.is(State.playing) && world.getSector() != null){
//all assigned missions are complete //all assigned missions are complete
if(world.getSector().completedMissions >= world.getSector().missions.size){ if(world.getSector().completedMissions >= world.getSector().missions.size){
Log.info("Mission complete.");
world.sectors().completeSector(world.getSector().x, world.getSector().y); world.sectors().completeSector(world.getSector().x, world.getSector().y);
world.sectors().save(); world.sectors().save();
gameOvers = 0; gameOvers = 0;
Settings.putInt("sector_x", world.getSector().x + world.getSector().size); Settings.putInt("sector_x", world.getSector().x + world.getSector().size);
Settings.save(); Settings.save();
netServer.kickAll(KickReason.sectorComplete); Call.onInfoMessage("[accent]Sector conquered![]\n" + roundExtraTime + " seconds until deployment in next sector.");
logic.reset();
playSectorMap(); playSectorMap();
}else if(world.getSector().currentMission().isComplete()){ }else if(world.getSector().currentMission().isComplete()){
//increment completed missions, check next index next frame //increment completed missions, check next index next frame