1
0
mirror of https://github.com/Anuken/Mindustry.git synced 2024-11-13 07:15:28 +03:00

Fixed #877 / Fixed #871 / Other fixes

This commit is contained in:
Anuken 2019-10-25 12:58:07 -04:00
parent 15cbc5fe42
commit b7e788d529
11 changed files with 50 additions and 23 deletions

View File

@ -14,6 +14,7 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:isGame="true"
android:appCategory="game"
android:usesCleartextTraffic="true"
android:label="@string/app_name"
android:theme="@style/GdxTheme" android:fullBackupContent="@xml/backup_rules">
<meta-data android:name="android.max_aspect" android:value="2.1"/>

View File

@ -472,7 +472,7 @@ public class NetClient implements ApplicationListener{
player.pointerX, player.pointerY, player.rotation, player.baseRotation,
player.velocity().x, player.velocity().y,
player.getMineTile(),
player.isBoosting, player.isShooting, ui.chatfrag.chatOpen(),
player.isBoosting, player.isShooting, ui.chatfrag.chatOpen(), player.isBuilding,
requests,
Core.camera.position.x, Core.camera.position.y,
Core.camera.width * viewScale, Core.camera.height * viewScale);

View File

@ -450,7 +450,7 @@ public class NetServer implements ApplicationListener{
float rotation, float baseRotation,
float xVelocity, float yVelocity,
Tile mining,
boolean boosting, boolean shooting, boolean chatting,
boolean boosting, boolean shooting, boolean chatting, boolean building,
BuildRequest[] requests,
float viewX, float viewY, float viewWidth, float viewHeight
){
@ -477,6 +477,7 @@ public class NetServer implements ApplicationListener{
player.isTyping = chatting;
player.isBoosting = boosting;
player.isShooting = shooting;
player.isBuilding = building;
player.buildQueue().clear();
for(BuildRequest req : requests){
if(req == null) continue;

View File

@ -76,6 +76,8 @@ public class Schematics implements Loadable{
target.tiles.clear();
target.tiles.addAll(newSchematic.tiles);
target.width = newSchematic.width;
target.height = newSchematic.height;
newSchematic.tags.putAll(target.tags);
newSchematic.file = target.file;

View File

@ -302,12 +302,12 @@ public class DesktopInput extends InputHandler{
player.clearBuilding();
}
if(Core.input.keyTap(Binding.schematic_select)){
if(Core.input.keyTap(Binding.schematic_select) && !ui.chatfrag.chatOpen()){
schemX = rawCursorX;
schemY = rawCursorY;
}
if(Core.input.keyTap(Binding.schematic_menu)){
if(Core.input.keyTap(Binding.schematic_menu) && !ui.chatfrag.chatOpen()){
ui.schematics.show();
}

View File

@ -401,6 +401,11 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
protected void flushSelectRequests(Array<BuildRequest> requests){
for(BuildRequest req : requests){
if(req.block != null && validPlace(req.x, req.y, req.block, req.rotation)){
BuildRequest other = getRequest(req.x, req.y);
if(other != null){
selectRequests.remove(other);
}
selectRequests.add(req.copy());
}
}

View File

@ -126,6 +126,8 @@ public class TypeIO{
if(!request.breaking){
buffer.putShort(request.block.id);
buffer.put((byte)request.rotation);
buffer.put(request.hasConfig ? (byte)1 : 0);
buffer.putInt(request.config);
}
}
}
@ -148,7 +150,12 @@ public class TypeIO{
}else{ //place
short block = buffer.getShort();
byte rotation = buffer.get();
boolean hasConfig = buffer.get() == 1;
int config = buffer.getInt();
currentRequest = new BuildRequest(Pos.x(position), Pos.y(position), rotation, content.block(block));
if(hasConfig){
currentRequest.configure(config);
}
}
reqs[i] = (currentRequest);

View File

@ -62,7 +62,7 @@ public class Mods implements Loadable{
file.copyTo(dest);
try{
loaded.add(loadMod(dest, false));
loaded.add(loadMod(dest));
requiresReload = true;
}catch(IOException e){
dest.delete();
@ -172,7 +172,7 @@ public class Mods implements Loadable{
Log.debug("[Mods] Loading mod {0}", file);
try{
LoadedMod mod = loadMod(file, false);
LoadedMod mod = loadMod(file);
if(mod.enabled() || headless){
loaded.add(mod);
}else{
@ -187,12 +187,13 @@ public class Mods implements Loadable{
//load workshop mods now
for(FileHandle file : platform.getWorkshopContent(LoadedMod.class)){
try{
LoadedMod mod = loadMod(file, true);
LoadedMod mod = loadMod(file);
if(mod.enabled()){
loaded.add(mod);
}else{
disabled.add(mod);
}
mod.addSteamID(file.parent().name());
}catch(Exception e){
Log.err("Failed to load mod workshop file {0}. Skipping.", file);
Log.err(e);
@ -399,7 +400,7 @@ public class Mods implements Loadable{
/** Loads a mod file+meta, but does not add it to the list.
* Note that directories can be loaded as mods.*/
private LoadedMod loadMod(FileHandle sourceFile, boolean workshop) throws Exception{
private LoadedMod loadMod(FileHandle sourceFile) throws Exception{
FileHandle zip = sourceFile.isDirectory() ? sourceFile : new ZipFileHandle(sourceFile);
if(zip.list().length == 1 && zip.list()[0].isDirectory()){
zip = zip.list()[0];

View File

@ -1,7 +1,9 @@
package io.anuke.mindustry.ui.dialogs;
import io.anuke.arc.*;
import io.anuke.arc.Net.*;
import io.anuke.arc.collection.*;
import io.anuke.arc.files.*;
import io.anuke.arc.util.*;
import io.anuke.arc.util.io.*;
import io.anuke.mindustry.gen.*;
@ -34,19 +36,27 @@ public class ModsDialog extends FloatingDialog{
ui.loadfrag.show();
Core.net.httpGet("http://api.github.com/repos/" + text + "/zipball/master", loc -> {
Core.net.httpGet(loc.getHeader("Location"), result -> {
try{
Streams.copyStream(result.getResultAsStream(), modDirectory.child(text.replace("/", "") + ".zip").write(false));
Core.app.post(() -> {
try{
mods.reloadContent();
setup();
ui.loadfrag.hide();
}catch(Throwable e){
ui.showException(e);
}
});
}catch(Throwable e){
ui.showException(e);
if(result.getStatus() != HttpStatus.OK){
ui.showErrorMessage(Core.bundle.format("connectfail", result.getStatus()));
ui.loadfrag.hide();
}else{
try{
FileHandle file = tmpDirectory.child(text.replace("/", "") + ".zip");
Streams.copyStream(result.getResultAsStream(), file.write(false));
mods.importMod(file);
file.delete();
Core.app.post(() -> {
try{
mods.reloadContent();
setup();
ui.loadfrag.hide();
}catch(Throwable e){
ui.showException(e);
}
});
}catch(Throwable e){
ui.showException(e);
}
}
}, t -> Core.app.post(() -> ui.showException(t)));
}, t -> Core.app.post(() -> ui.showException(t)));

View File

@ -69,7 +69,7 @@ public class Build{
/** Returns whether a tile can be placed at this location by this team. */
public static boolean validPlace(Team team, int x, int y, Block type, int rotation){
if(!type.isVisible() || type.isHidden()){
if(type == null || !type.isVisible() || type.isHidden()){
return false;
}

View File

@ -113,7 +113,7 @@ public class LiquidSource extends Block{
@Override
public void configured(Tile tile, Player player, int value){
tile.<LiquidSourceEntity>entity().source = content.liquid(value);
tile.<LiquidSourceEntity>entity().source = value == -1 ? null : content.liquid(value);
}
class LiquidSourceEntity extends TileEntity{